Hi all,
I got a report that need input file from user, I wish to automate it so if user had put the file in the path then run the report_code.sas , else send out an email to remind them.
What I plan to do is ,build a new control code, by using Macro to check fileexist , if yes , then run %include “&path./report_code.sas” , if no then send a auto email.
I just notice that %include in a macro will caused an error. Even though the %include was successfully run. Any other method can recommend to me to avoid the error due to %include in a macro ?
Thanks in advance !
I hope that when you get your logic to preform as expected that you don't spam the reports generator with the email, please send me the file """ every 5 minutes. People at work are trying to do the same thing not allowing enough sleep time.
"I just notice that %include in a macro will caused an error."
You can do what you want if your syntax is correct. We can't help much though if you don't share your not yet working code with us; plus the error in the log or a description of the undesired behavior and how it should behave.
hi Patrick, yes, I found my error and it' working ! thanks for the comment 😃
It's good that you found your solution, it would be even better if you shared it with the community so that others may also benefit.
Amir.
Sure!
%macro findfile;
%if %sysfunc(fileexist("&sharepath./INPUT/&filename..xlsx")) %then %do;
%include "&path./CODE/LI_main.sas";
%end;
%else %do;
FILENAME TESTMAIL EMAIL TO = (&mailto.)
CC = (&mailcc.)
FROM=&mailfrom.
SUBJECT = "Weekly Report (Automated Message)";
DATA _NULL_;
FILE TESTMAIL;
PUT "Hi &username.,";
PUT " ";
PUT "No input file in &sharepath./INPUT/&filename..xlsx ";
PUT "Extraction is aborted.";
PUT " ";
PUT "Thanks and regards,";
PUT "xx";
RUN;
%end;
%mend;
%findfile;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.