BookmarkSubscribeRSS Feed
helloSAS
Obsidian | Level 7

Is it possible in any case that sas can write out recrds to ouput dataset even with errors (any kind of errors) in the log.

I'm thinking of checking errors by looking at obs > 0 in the final data set. Is there any potential issues with this?

4 REPLIES 4
ballardw
Super User

Are you looking to send records with errors to a separate data set within a data step? It will depend on the types of 'error' encountered.

There is an automatic variable _ERROR_ in data vector that SAS will set to 1 for most error conditions. You can direct those records to a separate data set with code similar to :

Data NormalProcess Error;

     set have;

<program statements>

     if _error_= 1 then output Error;

     else output NormalProcess;

run;

Astounding
PROC Star

There are two potential issues off the top of my head.

First, the logic of that final DATA step may output zero observations, even if there are no errors.

Second, what if the final DATA step replaces an existing data set?  The final step might contain errors, yet the existing data set would not be replaced because of the errors.  When you check for the number of observations, you will find that observations exist because they were already there before the error-filled DATA step began.

helloSAS
Obsidian | Level 7

Thank you!

jakarman
Barite | Level 11

I you want to exclude the possibility of a program or executing error by checking the condition this way it is rather tricky.

Reasons:

- The last processing code need not to be something creating a dataset. Coud be a report processing

- Creating a dataset with 0 record can be the signal of a good processed flow when this dataset is the collection of error records

- When generating reports or flatfiles you are creating not sas-datasets but something else.   

SAS has many ways to validate the processing. The macro sysrc serves as condition code to the OS.

Even that way of checking is not 99,9% reliable. Sometimes you do not get any feedback or it an bug in errorchecking. 

Please can you explain your situation environment and what you are trying to achieve?.   

---->-- ja karman --<-----

sas-innovate-2024.png

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.

 

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.

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
  • 4 replies
  • 978 views
  • 3 likes
  • 4 in conversation