BookmarkSubscribeRSS Feed
pp2014
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..

5 REPLIES 5
jwillis
Quartz | Level 8

pp2014,

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.?


pp2014
Fluorite | Level 6

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

or

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

or

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

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

Reeza
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.

pp2014
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.

jwillis
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 ")                                                                                                                               
              TO=('firstname.lastname@address');
%if  &failed. = 1 %then %do;
                      put "    Sales data is missing        ";

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

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

%end;                                                                        
                    run; 
%mend mailerr;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 912 views
  • 0 likes
  • 3 in conversation