DATA Step, Macro, Functions and more

Error handling with LIBNAME XML

Posts: 55

Error handling with LIBNAME XML

Occasionally data providers to an application I'm working on send data that has not gone through an EBCIDIC to ASCII conversion. The rest of the XML file will be valid. The error message is:

ERROR: Character is unclassifiable.
encountered during XMLInput parsing
occurred at or near line 11, column 133

The application is batch and handles thousands of input files a run. Very few are ever wrong so I really need to be able to trap information about a problem file and keep on processing.

So far I have not found something equivalent to the DATA Step's _ERROR_ that indicates when a error has been encountered.

Does anybody know of any way to know that a LIBNAME XML translation has failed besides reading the sas.log after the fact?
Posts: 1,760

Re: Error handling with LIBNAME XML

You might want to look at whether syserr, sysrc and sysmsg variables contain anything useful.

If not, you might have to scan the files before hand in a data step and seek the culpable characters.
Posts: 66

Re: Error handling with LIBNAME XML

You may need to write a program using the macro variables that Chris suggested. Batch sas will go into syntax check mode when it finds an error. Various return codes issued by sas can be found at;

You would need to add a condition to your code like (not tested by myself though);

If &syserr eq 3 then do;

or the following may work also

%macro resetSysErr();
%let syserr = 0;
%mend resetSysErr;

and in your code-
if &syserr eq 3 then do;
put 'WARNING: xml file &filename returned errors.';
call execute('%resetSysErr();');

I might try the above tomorrow at work to see if that works. Let me know if you have success. Message was edited by: Cameron Lawson
Posts: 55

Re: Error handling with LIBNAME XML

Posted in reply to CameronLawson
I tried your suggestion to suppress the code and it did not work. SAS appears to bail as soon as the file read is attempted bypassing all data step statements after the SET.

I coded around this creating a macro flag. If the file can be read the flag is flipped past the SET. If the flag is not flipped, I know the file could not be read.

Of course the annoying ERROR: still shows in the log.

Scanning the files prior to processing is not an option due to data volume and a limited batch window. Message was edited by: JMarkW
Posts: 66

Re: Error handling with LIBNAME XML

maybe look at changing the for the batch server to no syntax mode? or add the nosyntaxcheck as a global option?
Ask a Question
Discussion stats
  • 4 replies
  • 3 in conversation