Learning SAS? Welcome to the exclusive online community for all SAS learners.

Importing XML to SAS University Edition

Accepted Solution Solved
Reply
Super Contributor
Posts: 250
Accepted Solution

Importing XML to SAS University Edition

[ Edited ]

Hi all

 

I got a question through Private Message and I'm proud to say I'm stumped :-)  The person is trying to import an XML dataset into SAS UE, and I thought for sure that the Import Data Task would have XML as an option - nope, no such luck.  I found the following code in this paper:

 

libname myxml xml 'U:\XML\subjects.xml';
libname dat 'U:\data\';
data dat.subjects;
  set myxml.subjects;
run;
proc print data = dat.subjects noobs;
run;

 

I'm running a Mac, so changed the two libname statement to the Mac format /Users/.../myfolders/ .  SAS successfully connected, and looked like it imported the data but the dataset was empty and I had no other information in the log.  

 

I know and have started using XML Mapper for work, but unfortunately there's no version of it for the Mac.  If anyone knows a way to import data into UE (with or without XML Mapper), I'd appreciate it.  

 

I've tried attaching the XML file I was using, but it appears to be removed when i post the message. The one I was using was from the Pubmed database and is one of their "sample" files for testing APIs, so I assume it's in proper form.

 

Thanks so much for your time,

Chris

Has my article or post helped? Please mark as Solution or Like the article!

Accepted Solutions
Solution
‎07-16-2016 06:11 AM
Super User
Posts: 10,023

Re: Importing XML to SAS University Edition

Posted in reply to DarthPathos

filename xx temp;
libname xx xmlv2 '/folders/myfolders/temp.xml' automap=replace xmlmap=xx;
proc copy in=xx out=work;
run;

View solution in original post


All Replies
Solution
‎07-16-2016 06:11 AM
Super User
Posts: 10,023

Re: Importing XML to SAS University Edition

Posted in reply to DarthPathos

filename xx temp;
libname xx xmlv2 '/folders/myfolders/temp.xml' automap=replace xmlmap=xx;
proc copy in=xx out=work;
run;

Super Contributor
Posts: 250

Re: Importing XML to SAS University Edition

thank you very much @Ksharp!  that worked perfectly!!

 

chris

Has my article or post helped? Please mark as Solution or Like the article!
SAS Super FREQ
Posts: 8,864

Re: Importing XML to SAS University Edition

Posted in reply to DarthPathos

Hi:

  XML must be all over the web. As an alternative to PROC COPY, you can use the DATA step, especially if you have any manipulation that needs to be done. More complicated structures will need to have an XML Map, but a simple structure, such as I show in the screen shot, the XML Libname Engine should work.

 

cynthia

 

see the screen shot posted here: https://communities.sas.com/t5/Base-SAS-Programming/How-can-I-import-XML-file-into-SAS/m-p/284023#M5...

Super Contributor
Posts: 250

Re: Importing XML to SAS University Edition

Posted in reply to Cynthia_sas
Thanks Cynthia! Hope you're having a good weekend :-)
Has my article or post helped? Please mark as Solution or Like the article!
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 449 views
  • 2 likes
  • 3 in conversation