BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SASAna
Quartz | Level 8

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

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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!

View solution in original post

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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!

SASAna
Quartz | Level 8
Worked really well. Thanks for the suggestion.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

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!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1197 views
  • 0 likes
  • 2 in conversation