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);
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.
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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.