SASUnit Examples  Version 1.3.0
linux/_dir.sas
Go to the documentation of this file.
1 
28 %MACRO _dir (i_path=
29  ,i_recursive=0
30  ,o_out=dir
31  );
32 
33  %LOCAL dirfile encoding s l_i_path;
34 
35  data &o_out ;
36  length filename $255;
37  format changed datetime20.;
38  run;
39 
40  %IF &syserr NE 0 %THEN %GOTO errexit;
41 
42  %LET encoding=wlatin1;
43  %LET dirfile=%sysfunc(pathname(work))/.dir.txt;
44  filename _dirfile "&dirfile" encoding=&encoding;
45 
46  %put &g_note.(SASUNIT): Directory search is: &i_path;
47 
48  %let l_i_path=%qsysfunc(tranwrd(&i_path, %str( ), %str(\ )));
49  %IF &i_recursive=0 %then %let s=-maxdepth 1;
50  %SYSEXEC(find -P &l_i_path. &s. -type f -printf "%nrstr(%h/%f\t%TD\t%TT\t\r\n)" > &dirfile. 2>/dev/null);
51 
52  data &o_out (keep=filename changed);
53  length filename $255;
54  format changed datetime20.;
55  infile _dirfile delimiter='09'x truncover;
56  input filename $ d:mmddyy8. t:time8.;
57  changed = dhms (d, hour(t), minute(t), 0);
58  run;
59 
60 %errexit:
61 %MEND _dir;