BookmarkSubscribeRSS Feed
tparvaiz
Obsidian | Level 7

Hi,

 

We send out reports via email. we have one project for each report and each report is sent out individually to multiple recipients

 

usually we run the sas code that generates an output in excel and then we manually send our emails and make attachments. The reason we do it is to ensure that we are not sending out garbage files (incase data is missing)

 

is there a way we can automate this process (with some sanity check, something like do a count of records and if the count is in between a defined range for the given report then send it out otherwise generate an error email to notify whoever looks after that report)?

 

Please assist

 

Thanks, in advance

1 REPLY 1
ArtC
Rhodochrosite | Level 12

Assuming that your check will be against the observation count in a data set, here is a little macro that i use to return the number of observations in a data set.

%macro obscnt(dsn); 
%local nobs dsnid rc;
%let nobs=.;

%* Open the data set of interest;
%let dsnid = %sysfunc(open(&dsn)); 

%* If the open was successful get the;
%* number of observations and CLOSE &dsn;
%if &dsnid %then %do; 
     %let nobs=%sysfunc(attrn(&dsnid,nlobs));
     %let rc  =%sysfunc(close(&dsnid)); 
%end;
%else %do; 
     %put WARNING: Unable to open &dsn;
     %put %sysfunc(sysmsg());
%end;

%* Return the number of observations;
&nobs 
%mend obscnt;

in your program you might use it something like:

%if %obscnt(mydata)>25 %then %do;

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
  • 1 reply
  • 553 views
  • 0 likes
  • 2 in conversation