вот быстрый макрос для извлечения списков каталогов на основе Windows в набор данных sas.
%macro DirList(dir);
/* %if &SUBDIR eq %then %let subdir=/s; */ /*** &SUBDIR not defined ****/
filename dirpipe pipe "dir &DIR.\*.* /s /-c";
data dir_list(label="Directory Listing [&DIR.]" drop=re_: _line_ date time);
format Path
File $250.
ModDT datetime19.
Size 16.
_line_ $32000. ;
if _N_ = 1 then do;
re_path=prxparse("/Directory of (.+)/");
re_subd=prxparse("/(\d\d\/\d\d\/\d\d\d\d)\s+(\d\d:\d\d [A|P]M)\s+\s+(\S.*)/");
re_file=prxparse("/(\d\d\/\d\d\/\d\d\d\d)\s+(\d\d:\d\d [A|P]M)\s+(\d+)\s+(\S.*)/");
retain re_: path;
end;
infile dirpipe lrecl=32000; input; _line_ = _infile_;
if lengthn(_line_)=0 then delete;
else
if prxmatch(re_path, _line_) then do;
path=prxposn(re_path, 1, _line_);
end;
else
if prxmatch(re_subd, _line_) then do;
date=input(prxposn(re_subd, 1, _line_), mmddyy10.);
time=input(prxposn(re_subd, 2, _line_), time6.);
ModDT=dhms(date, 0, 0, time);
File=prxposn(re_subd, 3, _line_);
size = .D; /*mark subdirectory records*/
if file not in ('.', '..') then output;
end;
else
if prxmatch(re_file, _line_) then do;
date=input(prxposn(re_file, 1, _line_), mmddyy10.);
time=input(prxposn(re_file, 2, _line_), time6.);
ModDT=dhms(date, 0, 0, time);
size=input(prxposn(re_file, 3, _line_), 16.);
file=prxposn(re_file, 4, _line_);
output;
end;
run;
filename dirpipe clear;
%mend;
и вот как их называют
%dirlist(c:);
%dirlist(c:\temp);
обратите внимание, что при указании базового каталога нет обратной косой черты. C:
не C:\
.