comp.soft-sys.sas - The SAS statistics package.
Hi. I have a process with several data and proc steps, all bound and up and tethered in a macro. Every now and then, one of the steps may fail, leading to a bunch of error messages from subsequent steps that depended on the errant output of the step that first failed. I'd like to be able to control the execution of subsequent steps based upon the success or failure of previous steps. But SAS doesn't seem to have a uniform way of doing this. I know some of the codes I can check: For libname statements, check &syslibrc. For data step errors, check &syserr. &syserr also appears to work for at least some PROC SQL errors. The documentation mentions &syslckrc for lock statements. There's also &sysrc, but I don't know whether that gives any error information. Right now I'm particularly interested in trapping errors from: data step, libname, proc datasets, proc format, proc optsave, proc optload, proc sort, proc sql, proc summary, proc surveyselect so if anyone can tell me how to trap errors from these procedures I'd certainly appreciate it (especially if they're not fully covered by syserr and syslibrc). Also, this list is sure to expand. Is there a document that collects all or most of the information on how to trap errors from various SAS procedures? Thanks! -- TMK -- "The Macro Klutz"
3. Error Trap
Hi! Is there a way to trap errors when running mactro? For example, if a macro is called to perform a data step including a "merge by" statement and the dataset included is not properly sorted, there will be an error and cause SAS to stop proceeding. Can the calling code trap this error code? Some applications use return codes for instances like this for calling code to take appropriate action. Is there a similar return code in SAS? If so, usually how is it handled in the calling code? TIA J S Huang
We are reading from XML files (XML libref) into SAS data sets. If there is an error in the XML (for example, a missing end tag), we want to be able to trap this error. We can use a DATA step, PROC COPY or PROC SQL to read from the XML libref into a SAS data set. However, even though there is an ERROR: message in the log window, SAS does not set the SYSERR (or SQLRC) macro variables after the DATA or PROC step finishes. Our only solution at this point is to redirect the log to a file right before the DATA or PROC step that reads the XML into a data set, then parse the log file, looking for "ERROR:". This is a pretty un-elegant solution. Is there a better way to handle this? Thanks in advance for all answers.
As part of a report we are making a large number of graphs. If for some reason no data is available for a particular client SAS graph does not produce the graph. Is there someway to trap this error so that we can handle the loss of the graph? Is there a macro variable set on error? Steve Bittner