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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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