DATA Step, Macro, Functions and more

List of all files in a location + Filename

Reply
Occasional Contributor
Posts: 15

List of all files in a location + Filename

Hi,

Please help me with this:

FILENAME prep FTP LIST CD="/env/prod"

HOST = "xxx.xx.xx"

USER = "abcdef" PASS="{sas001}234567ljX3J1bg==";

DATA in_list_file;

INFILE prep MISSOVER;

FORMAT permission $10.;

FORMAT code 3.;

FORMAT owner $10.;

FORMAT group $10.;

FORMAT size 15.;

FORMAT month $3.;

FORMAT day 2.;

FORMAT hour_year $5.;

FORMAT file $60.;

INFORMAT permission $10.;

INFORMAT code 3.;

INFORMAT owner $10.;

INFORMAT group $10.;

INFORMAT size 15.;

INFORMAT month $3.;

INFORMAT day 2.;

INFORMAT hour_year $5.;

INFORMAT file $60.;

INPUT permission $

code

owner $

group $

size

month $

day

hour_year $

file $

;

RUN;


But now we want to remove the ftp path and make to run with out FTP

so I changed as FILENAME prep LIST "/env/prod" ;

But I got message as ERROR: Invalid file, "/env/prod".

I have 3 .txt files (ABC, ABD, ABF) which has to taken into account.

Please let me know how can I get list of all files in the location(/env/prod) so that I can use the below
macro later to find out if input files are empty or not.

%MACRO CheckEmptyFile;

PROC SQL NOPRINT;

SELECT count(*) INTO :nn_obs FROM in_list_file WHERE file LIKE '%AB%' AND size = 0;

QUIT;



%PUT *** &nn_obs ***;



%IF &nn_obs > 0 %THEN %MailScript(Some SO input files are empty !!!);

%MEND CheckEmptyFile;

Please let me know how can I get list of all files in filename so that I can use the above
macro .

Thanks for the help.
Frequent Contributor
Posts: 102

Re: List of all files in a location + Filename

I use this little macro to determine the last modified date of the files in a path. It may help.

%macro LastFileModifiedDate(filename);
%global mod_date mod_time;
filename foo pipe "dir &filename /t:w /a:-d";

data _null_;

infile foo firstobs=6;

input mod_date ?? : mmddyy8. mod_time ?? & time8.;

if mod_date eq . then stop;

put mod_date= worddate. / mod_time= timeampm.;
call symput("mod_date",mod_date);
call symput("mod_time",mod_time);
run;
%put %sysfunc(putn(&mod_date,date7.));
%put %sysfunc(putn(&mod_time,time8.));

%mend;
%LastFileModifiedDate(c:\temp\License.txt);
Ask a Question
Discussion stats
  • 1 reply
  • 164 views
  • 0 likes
  • 2 in conversation