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
table_name | status |
table_1 | success |
table_2 | success |
table_3 | success |
table_4 | error |
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.