sas - searching several directories in a dataset with macro commands -
i have list of directories in form of work.directories.data, let's (variable directory). each row contains string looks this:
c:\importantfolder\subfolder\
i want find contents of each of these directories , combine them make new dataset. here have far:
%macro scandirec(string=); filename temptree pipe 'dir "&string" /s /b' lrecl=5000; data smalllist; infile temptree truncover; input dirlist $char1000.; run; data biglist; set biglist smalllist; run; %mend scandirec; data smalllist; run; data biglist; run; data _null_; set directories; call execute('%scandirectories('||directory||')'); run; i serious problems, think code looks pretty harmless. issue?
the error message seems pretty straight forward.
1 data test ; 2 infile 'dir "&string" /s /b' pipe truncover; 3 input dirlist $char1000.; 4 run; note: infile 'dir "&string" /s /b' is: unnamed pipe access device, process=dir "&string" /s /b,recfm=v, lrecl=32767 stderr output: file not found note: 0 records read infile 'dir "&string" /s /b'. note: data set work.test has 0 observations , 1 variables. note: data statement used (total process time): real time 0.99 seconds cpu time 0.04 seconds windows not find files named "&string".
use double quotes around strings if want sas resolve macro expressions.
"dir ""$string"" /s /b" or avoid macro completely.
data biglist; set directories; length cmd $500 ; cmd = catx(' ','dir',quote(trim(directory)),'/s /b'); infile cmd pipe filevar=cmd truncover end=eof; while (not eof); input dirlist $char1000.; output; end; run;
Comments
Post a Comment