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

Hi, 

I want to convert some xml files to a single sas dataset.

 

I am using the following code that I found on the internet somewhere, but I am getting an error called "XML describe error: XML table does not exist DETAIL."

 

options symbolgen;
libname outfile 'H:\test';
proc datasets lib=outfile kill; 
run;
quit;
%macro test(dir);
%let filerf=mydir;
%let rc=%sysfunc(filename(filerf,&dir)); 
%let did=%sysfunc(dopen(&filerf)); 
%let memcnt=%sysfunc(dnum(&did)); 
%let cnt=0;
%do i=1 %to &memcnt;
%let fname=%scan(%qsysfunc(dread(&did,&i)),1,’.’); 
%let cnt=%eval(&cnt+1);
%let name&cnt=&fname; 
%end;
filename SXLEMAP 'S:\program\case selection\iqi_xml_sfy2008.map'; 
%do i=1 %to &cnt; 
libname xml&i xml "&dir.\&&name&i...xml" xmlmap=sxlemap access=readonly;
proc datasets lib=xml&i; 
run;
proc append base=outfile.detail data= xml&i..detail force; 
run;
libname xml&i; 
clear;
%end;
%let rc=%sysfunc(dclose(&did)); 
%mend test;
%test(h:\xml temp);
1 ACCEPTED SOLUTION

Accepted Solutions
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, there's not much to add to the error message:

XML describe error: XML table does not exist DETAIL.

 

The table DETAIL does not exist in the XML file.  I have nothing further to go on.

 

If I was you I would start by importing one XML file, with some simple datastep code.  Once you have that working, then look at doing it for several files, but until you get a single bit of code working nothing else will.  All you need to start is:

 

libname myxml xml "h:\xml temp\file1.xml" xmlmap=sxlemap access=readonly;
data want;
set myxml.detail; /* <-- note here it is stating detail */
run;

You will note that a table "detail" is to be looked for in the XML file (in your original code):

proc append base=outfile.detail data= xml&i..detail force; 
run;

I expect that you just copy and pasted that, but you need to replace detail with the table in your XML.

 

One you have that running then a simple loop around it and you can import multiple files.

 

 

 

 

 

 

 

View solution in original post

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, there's not much to add to the error message:

XML describe error: XML table does not exist DETAIL.

 

The table DETAIL does not exist in the XML file.  I have nothing further to go on.

 

If I was you I would start by importing one XML file, with some simple datastep code.  Once you have that working, then look at doing it for several files, but until you get a single bit of code working nothing else will.  All you need to start is:

 

libname myxml xml "h:\xml temp\file1.xml" xmlmap=sxlemap access=readonly;
data want;
set myxml.detail; /* <-- note here it is stating detail */
run;

You will note that a table "detail" is to be looked for in the XML file (in your original code):

proc append base=outfile.detail data= xml&i..detail force; 
run;

I expect that you just copy and pasted that, but you need to replace detail with the table in your XML.

 

One you have that running then a simple loop around it and you can import multiple files.

 

 

 

 

 

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1130 views
  • 0 likes
  • 2 in conversation