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!
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.