BookmarkSubscribeRSS Feed
Mike_Davis
Fluorite | Level 6


Hello everyone,

I want to track error information after a whole SAS program has been finished,I know &syserr will set to 1 immediate after an error happen.

BUT &syserr will be override back to 0 when a NO-ERROR step was executed.

so finallly &syserr's value react for the last step. if the last step has error then &syserr will be set to 1,, otherwise will be 0.

MY question is: how we can know whether there was ANY error happened durng the whole program?------Any macro similar as &syserr but doesn't set back to 0?

PLEASE NOTICE:(suppose we CAN'T set a new macro variable after EACH process of the program.such as: %if &syserror=1 then %let flag='error happened" ,

this need too much extra work if there were too much process in the program,,,maybe there were 1000 datasteps and 500 procedures in the program...)

Thanks

Mike

/*sasprogram.sas*/

%put -----0 &syserr;

data a1;/*error happen here,*/

set sashelp.class2;

run;

%put -----1 &syserr;

/*

data a(n);

set sashelp.class;

run;

%put -----n &syserr;

*/

data a100;

set sashelp.class;

run;

%put -----100 &syserr;/*but here &syserror set back from 1 to 0,,,I want a value show us there was ever error happened during the whole program*/

5 REPLIES 5
Doc_Duke
Rhodochrosite | Level 12

How about just reading the log and searching for the text string 'error:'?  The Unix command "grep" has nice features for showing the error in context (and is also available for the PC).

I use it to search for warnings too, as they can actually be insidious errors.

Doc Muhlbaier

Mike_Davis
Fluorite | Level 6

Thank you Dr.Duke,

Your suggestion is very interesting to me! would you like to share your "grep" code under PC enviroment?

Thanks!

ScottBass
Rhodochrosite | Level 12

Google "findstr", here is one hit:  Findstr - Search for strings

You could also use Powershell but that would be slightly more complicated.  I do like Powershell's support of context, where you can print x number of lines before or after the text match.

Google "powershell select-string", here is one hit:  Select-String and Grep - Windows PowerShell Blog - Site Home - MSDN Blogs

HTH,

Scott


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
data_null__
Jade | Level 19

I think you want this one.

SYSCC Automatic Macro Variable


 

Contains the current condition code that SAS returns to your operating environment (the operating environment condition code). 

Type:Automatic macro variable (read and write)
Mike_Davis
Fluorite | Level 6

This really is a read and write automacro.I am trying to find a macro like this for a while

Thanks!

SYSCC is a read/write automatic macro variable that enables you to reset the job condition code and to recover from conditions that prevent subsequent steps from running. The values for SYSCC are: 

  • 0 is no errors no warnings 
  • 4 is warnings 
  • > 4 is an error occurred

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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