BookmarkSubscribeRSS Feed
jaxdaxter
Calcite | Level 5
I am trying to write some code which when the process errors a control table will be updated with certain values.
 

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.

3 REPLIES 3
ballardw
Super User

 

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?

jaxdaxter
Calcite | Level 5

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_namestatus
table_1success
table_2success
table_3success
table_4error

 

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.

SASKiwi
PROC Star

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. 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 475 views
  • 0 likes
  • 3 in conversation