Monday, February 10, 2014

Sending emails through SAS

I am not sure if there is any practical use for sending emails through SAS. But this SAS micro was picked up from RTP SAS User Group Email List and it works very well. The credit goes to Mr Ping Ling. 
 
 
 %macro sendemail(to=,cc=,subj=,msg1=,msg2=,msg3=,msg4=,msg5=,msg6=,msg7=,msg8=,attach=);
         FILENAME mail EMAIL (&to.)
         EMAILID='Microsoft Outlook'
         SUBJECT="&subj."
         %if &cc. ne %then %do;
           cc="&cc."
         %end;
         %if &attach. ne %then %do;
           attach="&attach."
         %end;
;
         %let today=%sysfunc(date(),date9.);

         DATA _NULL_;
           FILE mail;
           PUT "&today.";
           PUT;
           PUT "&msg1.";
           %do i=2 %to 8;
             %if &&msg&i. ne %then %do;
               %if %sysfunc(compress("&&msg&i."))="/n" %then %do; put; %end;
               %else %do; PUT "&&msg&i. "; %end;
             %end;
           %end;
           put;
         run;
%mend;

/*Example for using the macro
     %sendemail(to=%str('abc123@hotmail.com','xxx@gmail.com'),
                subj=%str(Sending email with SAS),
                msg1=%str(This is a test.),
                msg2=%str(/n),
                msg6=%str(xxxx)
                );

*/

3 comments:

21st Century Software Solutions said...

BASE SAS - http://www.21cssindia.com/courses/sas-clinical-online-training-153.html
Introduction To Sas System & Architecture - History And Various Modules - Features - Variables & Sas Syntax Rules - Sas Data Sets - Data Set Options - Operators - Multiple Observations and Multiple Datasets. - If – Then Else Statement - Where Statement - Creating & Redefining Variables - Select Statement - Infile Statement With Options - Input Styles - SAS Functions - Do Loops - Leave and Continue Statements - Output Statement & Put Statement - Stop And Error Statements - Array Statement - Modifying And Combining Data Sets - Updating Master Data Set - Key Board Macros & Add Abbreviations - Display Manager Commands - Proc Sort - Proc Print - Proc Means - Proc Freq - Proc Plot - Employees to learn at their own pace and maintain control of learning “where, when and how” with boundless access 24/7by 21st Century Software Solutions. contact@21cssindia.com

Unknown said...

It was really a nice article and i was really impressed by reading thisarticle We are also giving all software Course Online Training.The Sas Online Training is one of the leading Online Training institute in the world.

Unknown said...



This is the information that I was looking for and let me tell you one thing that is it is very useful for who is looking for SAS Online Training.