I want to send a report to myself every weekday even if the counts are zero..
My code so far..
proc sql;
create table cars_temp as
select make, origin, count(*) as total
from sashelp.cars
group by make, origin;
quit;
options emailsys=smtp emailhost=xxxxxxxxx emailport=25;
filename temp email
to = ( 'xxx@xxxxx.xom' )
from='xxx@xxxxx.xom'
subject="Daily discrepancies - &rptdt."
type="text/html"
ODS html body=temp style = journal;
TITLE justify= left "Below counts are calculated based on Yesterday's Date ";
*ods html text = "";
PROC REPORT DATA=cars_temp nowd HEADLINE HEADSKIP SPLIT='*'
style (report) = {background = white
font_face = "Verdana" font_size = 7pt just=left }
style (column) = {background = white CELLHEIGHT = 2.5%
font_face = "Verdana" font_size = 7pt just=left}
style (header) = {foreground = cx5e2750 font_face="Verdana"
font_size = 8pt just=left
background = white} ;
column A B C ;
define A / group width= 15 "Region * ID";
define B / group width= 30 "Region * Name";
define C / mean width= 30 "Total # * of items ";
run;
ods html text=" Daily counts";
ods html text = ".";
ods _all_ close;
Thank you
There are several ways to accomplish this but here's one from my code.
/* after your PROC SQL step, SQLOBS will have the record count */
%let itemcount=&sqlobs.;
%macro emailbody;
%if &itemcount. > 0 %then %do;
title "The following items were added in the past 5 days (&SYSDATE.)";
proc print data=recent;
run;
%end;
%else %do;
title;
ods text="NO recent items added (past 5 days).";
%end;
%mend;
filename msg email to=&TO_LINE.
FROM = "me@email.com"
subject="Recent entries as of &SYSDATE."
type='text/html'
CT ='text/html'
;
ods html(id=email)
file=msg
style=dove;
%emailbody;
ods html (id=email) close;
There are several ways to accomplish this but here's one from my code.
/* after your PROC SQL step, SQLOBS will have the record count */
%let itemcount=&sqlobs.;
%macro emailbody;
%if &itemcount. > 0 %then %do;
title "The following items were added in the past 5 days (&SYSDATE.)";
proc print data=recent;
run;
%end;
%else %do;
title;
ods text="NO recent items added (past 5 days).";
%end;
%mend;
filename msg email to=&TO_LINE.
FROM = "me@email.com"
subject="Recent entries as of &SYSDATE."
type='text/html'
CT ='text/html'
;
ods html(id=email)
file=msg
style=dove;
%emailbody;
ods html (id=email) close;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.