Hello SAS Comm,
Need some help with parsing a HTML batch file in order to create a SAS dataset. Attached is a sample of the HTML batch file containing two dummy data records. Each records begins at the line = <Application> and ends at the line </Application>. In a real life example the batch file will contain many thousands of records. Any assistance would be greatly appreciated. Thanks
What you included is looking like a part a XML file. Is that what you to ceate or is it like AJAX?
It would be coming out of something like AJAX as it is via a B2B process. I just kept the first two records (<Application> x 2) from a recent file transfer. I though it was XML too but when I tried using the XML libname engine to assist with importing into a SAS data set it came back with errors saying iot wasn't in XML format? I'll try it again using the full file unedited.
Tried the original file with the XML libname engine and still get the same error as per my sample file -
18 data xml;
19 set in.CREATE_201402070702184;
ERROR: Physical file does not exist, \\fp02syd\analytics$\08_Users\Dave_H\EBDM\cba_dua_data\CREATE_201402070702184.xml.
encountered during XMLMap parsing
occurred at or near line 1, column 1
XML file is empty, corrupt, or XML data is not in a format supported by the XML libname engine: CREATE_201402070702184
ERROR: XML describe error: Internal processing error.
20 run;
The root error is "Physical file does not exist". Try to repair that (physical filename should end with .xml instead of .html) before advancing.
You cannot read always a XML file that way as there are many conventions with XML and not all are known. There must be a header of some type (did not see that).
There is a XMLMapper tool on the BI instalation that will roll out that tool. It will help to set up a translation definition. SAS(R) 9.3 XML LIBNAME Engine: User's Guide, Second Edition
Cheers. Thanks for you help.
As Jaap suggested, it looks like it is a XML file . and what output you need ?
data x;
infile 'c:\temp\HTML_batch_file_sample.html' dsd dlm='<>' ;
input @'>' x : $100. @@;
if not missing(x);
run;
Xia Keshan
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.