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