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?
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;
Use SAS XML Mapper tool. This will create the SAS code and XML maps needed to read your XML into a SAS dataset.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.