BookmarkSubscribeRSS Feed
zolagola
Calcite | Level 5

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

7 REPLIES 7
jakarman
Barite | Level 11

What you included is looking like a part a XML file. Is that what you to ceate or is it like AJAX?

---->-- ja karman --<-----
zolagola
Calcite | Level 5

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.

zolagola
Calcite | Level 5

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;

jakarman
Barite | Level 11

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

---->-- ja karman --<-----
zolagola
Calcite | Level 5

Cheers. Thanks for you help.

Ksharp
Super User

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

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1791 views
  • 3 likes
  • 4 in conversation