Hi SAS Users,
Need some help with displaying the Table contents into Email.
I have a variable called "FILENAME" in a table 'FILES_TABLE" where i stored all the filenames of 500 length. I have to put them in the email. & i used "PUT" statement like below code.
%if &syserr=0 %then %do;
FILENAME outmail EMAIL
SUBJECT = "TEST FILES"
FROM = "xyz@xyz.com"
TO = "&to_email"
DATA _NULL_;
FILE outmail;
PUT "Hi All,";
PUT " ";
PUT "The following files have been created and dropped in the following path.";
PUT " ";
PUT "&filename";
PUT "Thanks,";
run;
I am seeing all the files, but they are coming in same line, or broken filenames in different lines, Dispaly is not clean. Due to one PUT staetement for all the files.
Any suggestions to make files look clean & orderly in the Email?
Thanks,
Ana
The reason all the filenames are coming out on one line is because you are outputting a string from macro varaible &filename. You will need to loop of the macro list, if its comma separated then:
filename outmail email subject="test files" from="xyz@xyz.com" to="&to_email"; data _null_; file outmail; length fn $2000; put "hi all,"; put " "; put "the following files have been created and dropped in the following path."; put " "; do i=1 to countw("&filename.",","); fn=scan("&filename.",i,","); put fn; end; put "thanks,"; run;
As always though, I would advise to avoid macro lists. Put your data in datasets and process it from there, its what dataset are for.
Oh, and there really is no need to code all in upcase!
The reason all the filenames are coming out on one line is because you are outputting a string from macro varaible &filename. You will need to loop of the macro list, if its comma separated then:
filename outmail email subject="test files" from="xyz@xyz.com" to="&to_email"; data _null_; file outmail; length fn $2000; put "hi all,"; put " "; put "the following files have been created and dropped in the following path."; put " "; do i=1 to countw("&filename.",","); fn=scan("&filename.",i,","); put fn; end; put "thanks,"; run;
As always though, I would advise to avoid macro lists. Put your data in datasets and process it from there, its what dataset are for.
Oh, and there really is no need to code all in upcase!
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.