- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I am running SAS in a Unix environment. I am attempting to do a grep of the errors in the directory containing all of my SAS logs, place the results in a macro variable, and include the results in the body of an email. The code works, but the output in the body of the email only includes the first 2 lines out of several (around 20 or more) produced by the grep command.
What can I change in order to have my email body include ALL of the lines produced by the grep command? Please reply with examples. Thanks.
data _null_;
infile "cd /err/kept/here/;grep ERROR: *.log" pipe truncover;
length x $300.;
input x $300.;
call symputx('errors',x);
run;
FILENAME Mailbox EMAIL
SUBJECT="Email Containing Errors in SAS Code"
content_type="TEXT/PLAIN";
data _null_;
file Mailbox TO='<myemailadr@yahoo.com>';
put "Here are today's errors:";
put "&errors.";
run;
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Maybe try like this:
FILENAME Mailbox EMAIL
SUBJECT="Email Containing Errors in SAS Code"
content_type="TEXT/PLAIN";
data _null_;
file Mailbox TO='<myemailadr@yahoo.com>';
if _N_=1 then put "Here are today's errors:";
infile "cd /err/kept/here/;grep ERROR: *.log" pipe truncover;
length x $300.;
input x $300.;
put x;
run;
All the best
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Currently you are placing all of the output into a single macro variable.
I am going to guess that the result you see if from the "last" set of errors. With the single macro variable each log file read is going to overwrite the macro variable and the result is only from the last file.
I would create an actual data set instead of the DATA _NULL_ to collect the output. Then you have some data to examine.
And use that data set with PUT instead of macro variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Maybe try like this:
FILENAME Mailbox EMAIL
SUBJECT="Email Containing Errors in SAS Code"
content_type="TEXT/PLAIN";
data _null_;
file Mailbox TO='<myemailadr@yahoo.com>';
if _N_=1 then put "Here are today's errors:";
infile "cd /err/kept/here/;grep ERROR: *.log" pipe truncover;
length x $300.;
input x $300.;
put x;
run;
All the best
Bart
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation