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.

sas-innovate-2024.png

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.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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