BookmarkSubscribeRSS Feed
Fluorite | Level 6

I have dataset with date and working day flag(1 is working and 0 means non-working day). Then

I have sales dataset with sales number and sales_date.  I have another dataset with Inventory number and  Inv_date.

What  I have to do is, check if everyday if current day is working day or not.   If it is working day then check if there are sales for today from Sales dataset and  Inventory for today from Inventory dataset, If  either Sales or Inventory or both conditions are not satisfied then send email through SAS saying that "Sales data is missing for today or Inventory data is missing or Both data are missing".

Any help in this will be greatly appreciated..

Quartz | Level 8


What do you want sent in your email?  A file of errant info attached to the email; a list of errant info in a txt file attached to the email;  a line of text in the email itself for each errant row? The data can be analyzed wth a data step or sql step or something else.  Which do you prefer?  Are you emailing from your PC or a remote session such as a mainframe or unix or etc.?

Fluorite | Level 6

I want to send the email saying that "Sales data and Inventory data missing"  /*** if both data are missing *********/ 


"Sales data is missing"  /*****if only sales data is missing  *******/


"Inventory data is missing"  /*****if only Inventory data is missing  *******/

I will be mailing from PC.    SAS running on Windows 7 environment.

Super User

I'm assuming you're running this on a daily basis? Would it be checking for the same day or for the previous day?

Id also recommend checking the number of records vs the expected status.

Fluorite | Level 6

I will be running it on daily basis and checking for the same day.   Yes I would check for records for that day so that I can send email based on which dataset has 0 records.

Quartz | Level 8

SQL code can build, compare the three datasets and decide which &failed. condition exists.  When the SQL is complete, execute the macro.  There are also ways other than SQL to decide which of the three failed conditions exist.

%macro mailerr;
                    filename mymail email;                                                                                                                              

                    data _null_;                                                                                                                                           
                      file mymail                                                                                                                                          
       subject=(" Put your subject here ")                                                                                                                               
%if  &failed. = 1 %then %do;
                      put "    Sales data is missing        ";

%if &failed. = 2  %then %do;                                                                         
                      put  "Inventory data is missing"        ;  

%if &failed. = 3 %then %do;                                                                     
                      put   "Sales data and Inventory data missing"     ;    

%mend mailerr;


Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.


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
  • 5 replies
  • 3 in conversation