BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jonam
Calcite | Level 5

Hi,

Is there any way we can create datasets from XML file without using XML engine? I don't have xml engine.

What is the easiest and best method to create sas datasets from xml file using base sas?

1 ACCEPTED SOLUTION

Accepted Solutions
FriedEgg
SAS Employee

It is not a licenced product, it is just part of Base SAS so you will not see it listed by proc setinit.

Try running this.

filename yt url 'http://gdata.youtube.com/feeds/api/videos/pzI4D6dyp_o/comments?v=2&max-results=50&start-index=1';

libname ytube xml xmlfileref=yt;

data ytube;

set ytube.entry;

run;

This is without defining a proper xml map for this feed so it is not perfect, just to show you that you can use xml engine.

View solution in original post

4 REPLIES 4
FriedEgg
SAS Employee

The XML LIBNAME Engine is a part of Base SAS since at least version 8.2

jonam
Calcite | Level 5

Really....I'm using SAS 9.1. I checked it by running proc setinit; run; I didn't see xml engine. 

How can i use the xml libname engine in base sas.

Thanks a ton for your quick responese.

FriedEgg
SAS Employee

It is not a licenced product, it is just part of Base SAS so you will not see it listed by proc setinit.

Try running this.

filename yt url 'http://gdata.youtube.com/feeds/api/videos/pzI4D6dyp_o/comments?v=2&max-results=50&start-index=1';

libname ytube xml xmlfileref=yt;

data ytube;

set ytube.entry;

run;

This is without defining a proper xml map for this feed so it is not perfect, just to show you that you can use xml engine.

Cynthia_sas
SAS Super FREQ

Hi:

  Since the XML Libname Engine is part of Base SAS, you won't see it in PROC SETINIT. (you don't see PROC PRINT, FREQ or MEANS in SETINIT either, but you can still use them).

  OK...let's assume that you have an XML file stored in c:\temp\giftidea.xml (as shown in the attached screenshot). Then this code (in 9.2 or higher) would read the XML file into a SAS dataset:

** for 9.2;
/* libname giftxml xml92 'c:\temp\giftidea.xml';  */
  
 
** for 9.1.3;
libname giftxml xml 'c:\temp\giftidea.xml';
 
proc contents data=giftxml._all_;
run;
   
data mygifts;
   set giftxml.giftidea;
run;
 
proc print data=work.mygifts;
run;
  
libname giftxml clear;

  If your data are not in a simple structure, as defined in the doc for the Libname Engine, then you would have to use an XML Map file to map from more hierarchical XML to SAS dataset form.

cynthia


pix_giftidea_xml.jpg

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!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 922 views
  • 3 likes
  • 3 in conversation