BookmarkSubscribeRSS Feed
Sandhyaa
Calcite | Level 5

We have a requirement to convert an xml data into sas dataset. The values are stored within attributes of the elements. We can only parse the element values and convert into dataset. Is there any solution to convert attribute values into dataset columns?

2 REPLIES 2
Tom
Super User Tom
Super User

Sounds like you have XML stored in datasets (rather than in-line with the program).

If your data is actually in a database server like Oracle then using their built in tools to create a view would probably be the best.

Otherwise it is possible to write the data to text file and use SAS's XML engine to read it as a dataset.  Will probably take some time to figure out how to generate the proper map to read it.  Also SAS much prefers that the XML is nice a simple, but if it was that simple then you probably would have just stored it as variables to begin with.

filename xmlfile temp;

data _null_;

  set have;

  file xmlfile ;

  put xmlvar ;

run;

libname xmlfile xml ;

data want ;

  set xmlfile.table1 ;

run;

DanK
Calcite | Level 5

Use SAS XML Mapper tool.  This will create the SAS code and XML maps needed to read your XML into a SAS dataset.

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 835 views
  • 0 likes
  • 3 in conversation