Hello,
I have table containing email address , name and names of files. I have to sand an email to each person and writing down the list of files' names.
I created a macro %putt that can do what I'm looking for.
filename MYEMAIL email;
data _null_;
set password_name_path;
file MYEMAIL;
%MACRO PUTT(NBR);
%DO I = 1 %TO &NBR;
PUT file&I ;
put ;
%END;
%MEND PUTT;
put '!EM_TO!' mail;
put '!EM_FROM!' "XXX@gmail.com";
/*put '!EM_CC!' " ";*/
put '!EM_SUBJECT! File’sname ' ;
put "Hello "name "," ;
put ;
put "======================================================================================================";
put ;
put "the names files are :" ;
put ;
%PUTT(&maxfile);
put ;
put "======================================================================================================";
put '!EM_SEND!';
put '!EM_NEWMSG!';
put '!EM_ABORT!';
run;
&maxfile is a macro variable which has the max value of numbers of file. 4 in the example above.
The program works properly but I have 4 lines for each email sent by SAS.
can anyone help me how to put avoid printing black lines when we have only some files (file1, file2 for exp).
Thank you
Thank you for your answer.
You're right. But what I'm asking for is how to write a code to tell sas to put file1 and stops instead of putting 3 blank lines.
Note : the value of macro variable "&maxfile" =4
May be adding a do loop?
Thanks,
Hi @Nihal, here's an alternative just listing the filenames on one row. When I have short emails like this I also put the same information in the subject line so that I don't even have to open the email. In the put statements, the / tells SAS to go to a new line (making a blank line).
filename MYEMAIL email; data _null_; set password_name_path; maxfile = CATX(' ', file1, file2, file3, file4); file MYEMAIL; put '!EM_TO!' mail; put '!EM_FROM!' "XXX@gmail.com"; put '!EM_SUBJECT!' 'the names files are: ' maxfile ; put "Hello " name "," ; put / "======================================================================================================"; put / "the names files are: " maxfile ; put / "======================================================================================================"; put '!EM_SEND!'; put '!EM_NEWMSG!'; put '!EM_ABORT!'; run;
Hope this helps.
Hi @Nihal, here's another version with the files listed on separate lines (and I used the shortcut notation for the dashed lines):
filename MYEMAIL email;
data _null_;
set password_name_path;
maxfile = CATX(' ', file1, file2, file3, file4);
file MYEMAIL;
put '!EM_TO!' mail;
put '!EM_FROM!' "XXX@gmail.com";
put '!EM_SUBJECT!' 'the names files are: ' maxfile ;
put "Hello " name "," ;
put / 30*"=";
put / "The names files are:";
if file1 > '' then put / file1;
if file2 > '' then put / file2;
if file3 > '' then put / file3;
if file4 > '' then put / file4;
put / 30*"=";
put '!EM_SEND!';
put '!EM_NEWMSG!';
put '!EM_ABORT!';
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.