Help using Base SAS procedures

SAS error information

Reply
Regular Contributor
Posts: 222

SAS error information


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 NOTICESmiley Sadsuppose 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*/

Trusted Advisor
Posts: 2,113

Re: SAS error information

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

Regular Contributor
Posts: 222

Re: SAS error information

Thank you Dr.Duke,

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

Thanks!

Super Contributor
Posts: 377

Re: SAS error information

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

Respected Advisor
Posts: 3,777

Re: SAS error information

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)
Regular Contributor
Posts: 222

Re: SAS error information

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
Ask a Question
Discussion stats
  • 5 replies
  • 232 views
  • 3 likes
  • 4 in conversation