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

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.

1 ACCEPTED SOLUTION

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

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 🐵  

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

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

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 🐵  

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.

Aditi24
Obsidian | Level 7

Thank you so much for your help :). 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 😛

Anyway, thanks a lot!! 🙂

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
  • 886 views
  • 2 likes
  • 2 in conversation