BookmarkSubscribeRSS Feed
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;
%else %do;
%put it is fine;


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.

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";

Can you show exactly what you expect the data set Error_status to hold? How do expect to use the data set later?

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




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.

Opal | Level 21

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. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3 in conversation