BookmarkSubscribeRSS Feed
JMarkW
Fluorite | Level 6
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?
4 REPLIES 4
ChrisNZ
Tourmaline | Level 20
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.
CameronLawson
Obsidian | Level 7
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;
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/a000208995.htm

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

If &syserr eq 3 then do;
options NOSYNTAXCHECK;
end;

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();');
end;

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
JMarkW
Fluorite | Level 6
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
CameronLawson
Obsidian | Level 7
maybe look at changing the autoexec.sas for the batch server to no syntax mode? or add the nosyntaxcheck as a global option?

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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