For the moment I have the following but gives a warning creating a work table called error_table and a column called status but no values. I have simplified the table I'm trying to create.
%macro error_check; %if &syserr > 0 %then %do; %put This process has errored with the following message: &syserrortext; %put Writing out status "error" to control table; data error_table; status = error; run; %end; %else %do; %put it is fine; %end; %mend;
Unfortunately I can't seem to get the code working. This is the first time I've used the &syserr macro so I'm wondering if I'm using it wrong should be using some other method. Thanks for any help one can give.
I think what you may have intended was more like this if you intended to create character variable that said "error". Your current code uses an undefined variable named error, which will default to numeric and missing. Then assign that missing value to the variable Status.
data error_table; status = "error"; run;
Can you show exactly what you expect the data set Error_status to hold? How do expect to use the data set later?
I've simplified to what I want the table to look like.
Basically a SAS program is running which is processing tables in sequence and I want a table giving a running commentary on the tables status. This program runs at set times. So for example it will run, process 2 tables, stop. Then the next day it will run and process 1 table. For example it may look like this
If the program errors I would like to update this control table to say that the status of the table is errored.
It's required basically because that's what the end user wants.
What is your actual use case here? Checking the return code of every DATA step isn't going to tell you if it was successful or not, it will only tell you if there were no errors or warnings. A DATA step can run without errors but not have the correct data for example. Only examining the SAS log will offer more evidence of success or not.
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.