1

I have a 5GB size XML data file and I need that imported to SAS. I am trying using libname and its still running and running

     libname in xml 'C:\Test\Datafile.xml';
     
      data want;
       set in.want;
      run;

Is there a better way to import this file?

Thanks

ckp
  • 579
  • 2
  • 10
  • 27
  • 1
    Do you know what is in the file? How the XML is constructed? How you want to map it to a SAS dataset or datasets? I would try the XMLV2 engine instead of the older XML engine. Do you know how to create the map file that the XML engine(s) use? It might help to do that first instead of asking SAS to try to figure it out from looking at the file. – Tom Sep 03 '20 at 12:58
  • Thanks, Tom - It must be column level data. I tried using SAS XML mapper and it crashed because of the file size. I even tried XMLV2 in my libname statement and I had not compatible error – ckp Sep 03 '20 at 13:42
  • You don't have to use XML mapper to build a map file. It is just a text file. You can build it yourself with any text editor if you understand the syntax. You might have better luck using external XML parsing tools to convert the file into one or more simple rectangular files, like CSV files for example. – Tom Sep 03 '20 at 15:50
  • What is the structure of the XML? Please post a sample with enough repeating nodes to understand structure in body of question (not as an image). – Parfait Sep 06 '20 at 18:47

1 Answers1

2

Method 1 - Which is what you are doing.

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; 

Method - 2 Using Proc copy

libname myxml xml 'U:\XML\subjects.xml'; 
libname dat 'U:\data\'; 

proc copy in=myxml out=dat;
run;

Method 3 - Using xmlmap

filename path 'U:\XML\path.xml';
filename map 'U:\XML\path.map';
libname path xml xmlmap=map;
proc print data=path.ford noobs;
run; 

Method - 4 Using excel

PROC IMPORT OUT=subjects DATAFILE="U:\subjects.xls" DBMS=xls;
 GETNAMES=yes;
RUN;

Everything in detail is available in this fantastic global forum paper.

Keneni
  • 705
  • 5
  • 12