DATA Step, Macro, Functions and more

Sending Email with SAS 9.3

Accepted Solution Solved
Reply
Contributor
Posts: 71
Accepted Solution

Sending Email with SAS 9.3

Hi,

 

I want to embed the contents of a log file in mail body and send it using SAS 9.3. I am able to send attachments but I want to send the contents of file in mail body. Please help.


Accepted Solutions
Solution
‎09-25-2015 06:23 AM
Super User
Super User
Posts: 7,981

Re: Sending Email with SAS 9.3

Should be quite straight forward.  Run your program, that creates a log file.  Then have another program which runs, does a datastep infile read in of the text file and then creates the email.

data temp;

  infile "thelog.log";

  input text $200.;

run;

filename mymail email 'someone@somewhere'  subject='Log file';

data _null_;
  file mymail;

  set temp;
  put text;
run;

 

However I would strongly advise against this approach.  The reason being is that logs can get very big ver quickly.  If your sending out hundreds of pages of email each time your IT people will cut you off Smiley Surprised)  

Why do you need to send the log?  Why not pre-process the log to find any errors/warnings and only send that minimal information out.  Why use email at all, SAS has some enterprise setups to do this kind of automation (stored process springs to mind), and there are plenty of other tools out there as well.

View solution in original post


All Replies
Solution
‎09-25-2015 06:23 AM
Super User
Super User
Posts: 7,981

Re: Sending Email with SAS 9.3

Should be quite straight forward.  Run your program, that creates a log file.  Then have another program which runs, does a datastep infile read in of the text file and then creates the email.

data temp;

  infile "thelog.log";

  input text $200.;

run;

filename mymail email 'someone@somewhere'  subject='Log file';

data _null_;
  file mymail;

  set temp;
  put text;
run;

 

However I would strongly advise against this approach.  The reason being is that logs can get very big ver quickly.  If your sending out hundreds of pages of email each time your IT people will cut you off Smiley Surprised)  

Why do you need to send the log?  Why not pre-process the log to find any errors/warnings and only send that minimal information out.  Why use email at all, SAS has some enterprise setups to do this kind of automation (stored process springs to mind), and there are plenty of other tools out there as well.

Contributor
Posts: 71

Re: Sending Email with SAS 9.3

Thank you so much for your help Smiley Happy. And yeah..the log file which will be generated will hold the output of 2 batch commands and is very short. So, there is very less chance of people cutting me off Smiley Tongue

Anyway, thanks a lot!! Smiley Happy

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 237 views
  • 2 likes
  • 2 in conversation