Macro to check if file exists ,sleep and send email

Reply
Contributor
Posts: 44

Macro to check if file exists ,sleep and send email

Hi All,

I wrote the below program,so that it can check for the files,sleep for a while check again and if the files are not found then, send an email with the missing file names.

the below program works,however it sends separate emails for every missing file.

I wanted to know if it is possible to have one email which states all the missing files.

File 2 & 3 are missing.

Any help would be great..

%macro file_exits (mMyFile, HowOfftenToTest, HowLongBetweenTests, EmailAdress);

%let fc = %sysfunc(fileexist(&mMyFile));

%if &fc = 1 %then

%put "Files received";

%else;

data _null_;

call sleep(&HowOfftenToTest,&HowLongBetweenTests);

run;

%if &fc=0 %then %do;

%PUT "EMAIL";

FILENAME EML EMAIL  TO = ("&EmailAdress")

   SUBJECT =  "Files not found";

DATA _NULL_;

FILE EML;

PUT "&mMyFile does not exist" ;

run;

%end;

%mend file_exits;

%file_exits(/mie/data/test3.txt, 2, 10, Me@internet.com);

%file_exits(/mie/data/test2.txt, 2, 10, Me@internet.com);

%file_exits(/mie/data/test1.txt, 2, 10, Me@internet.com);

Valued Guide
Posts: 3,208

Re: Macro to check if file exists ,sleep and send email

redesign your program.....     You want a list of missings files, than first build that list.

A lot of this kind of functionality may be already there with schedulers. Just use available tools instead of inventing them again.

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 1 reply
  • 501 views
  • 0 likes
  • 2 in conversation