labradorchik
asked on
SAS Error codes/variables
SAS codes (SYSCC, SYSRC, and SYSERR) indicate different log results when SAS programs run in UNIX or PC SAS. Which is the best or most efficient way to use these codes?
This is how I use SAS macro exit codes in my SAS:
I would like to hear how the rest of you handle SAS exit/return codes?
This is how I use SAS macro exit codes in my SAS:
data _null_;
X "echo &syscc > progerr.txt";
run;
%put syserr= &syserr syscc = &syscc sysrc = &sysrc;
I would like to hear how the rest of you handle SAS exit/return codes?
ASKER
ShannonEE, thank you very much for your explanations!!
I had to read a few times to grasp the whole idea behind it. :)
I guess the only question I have is which return error code is most efficient to use?
SYSCC, SYSRC, or SYSERR?
I had to read a few times to grasp the whole idea behind it. :)
I guess the only question I have is which return error code is most efficient to use?
SYSCC, SYSRC, or SYSERR?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi ShannonEE,
Sorry for the late response but I had to do some testing in order to understand this process fully. Everything now makes sense to me. Thank you very much for all your explanations! I really appreciate your help!!
Sorry for the late response but I had to do some testing in order to understand this process fully. Everything now makes sense to me. Thank you very much for all your explanations! I really appreciate your help!!
The whole point of error codes is to allow conditional processing under program control.
As an example of using various SAS return codes, the following macro
{% DefineLib(ref, path) }
allocates a library to a defined location.
Essentially it does a
libname ref "path";
but under script control so that it ensures that any calling script won't proceed if the library cannot be allocated for any reason eg network drive not allocated, the folder location deleted, .... Note that it produces a LOG message and returns without failing if the libname already is allocated to a library. You could easily change this behavior.
It runs in an environment of enterprise guide which does ODS output to HTML. Hence the possible error report is generated into the output stream as HTML.
It is set up as an autocall sas macro which puts a one line note in the log when it is defined (on first use).
Open in new window
The usefullness of the return codes is to actually use the return code to conditionally do something in the macro code. Just printing out the RC value is a bit lame.
Regards,
Ian