<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Convert different XML files to a combined SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Convert-different-XML-files-to-a-combined-SAS-dataset/m-p/455892#M284332</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to convert some xml files to a single sas dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;options symbolgen;
libname outfile 'H:\test';
proc datasets lib=outfile kill; 
run;
quit;
%macro test(dir);
%let filerf=mydir;
%let rc=%sysfunc(filename(filerf,&amp;amp;dir)); 
%let did=%sysfunc(dopen(&amp;amp;filerf)); 
%let memcnt=%sysfunc(dnum(&amp;amp;did)); 
%let cnt=0;
%do i=1 %to &amp;amp;memcnt;
%let fname=%scan(%qsysfunc(dread(&amp;amp;did,&amp;amp;i)),1,’.’); 
%let cnt=%eval(&amp;amp;cnt+1);
%let name&amp;amp;cnt=&amp;amp;fname; 
%end;
filename SXLEMAP 'S:\program\case selection\iqi_xml_sfy2008.map'; 
%do i=1 %to &amp;amp;cnt; 
libname xml&amp;amp;i xml "&amp;amp;dir.\&amp;amp;&amp;amp;name&amp;amp;i...xml" xmlmap=sxlemap access=readonly;
proc datasets lib=xml&amp;amp;i; 
run;
proc append base=outfile.detail data= xml&amp;amp;i..detail force; 
run;
libname xml&amp;amp;i; 
clear;
%end;
%let rc=%sysfunc(dclose(&amp;amp;did)); 
%mend test;
%test(h:\xml temp);&lt;/PRE&gt;</description>
    <pubDate>Fri, 20 Apr 2018 11:17:35 GMT</pubDate>
    <dc:creator>katariasarthak</dc:creator>
    <dc:date>2018-04-20T11:17:35Z</dc:date>
    <item>
      <title>Convert different XML files to a combined SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-different-XML-files-to-a-combined-SAS-dataset/m-p/455892#M284332</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to convert some xml files to a single sas dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;options symbolgen;
libname outfile 'H:\test';
proc datasets lib=outfile kill; 
run;
quit;
%macro test(dir);
%let filerf=mydir;
%let rc=%sysfunc(filename(filerf,&amp;amp;dir)); 
%let did=%sysfunc(dopen(&amp;amp;filerf)); 
%let memcnt=%sysfunc(dnum(&amp;amp;did)); 
%let cnt=0;
%do i=1 %to &amp;amp;memcnt;
%let fname=%scan(%qsysfunc(dread(&amp;amp;did,&amp;amp;i)),1,’.’); 
%let cnt=%eval(&amp;amp;cnt+1);
%let name&amp;amp;cnt=&amp;amp;fname; 
%end;
filename SXLEMAP 'S:\program\case selection\iqi_xml_sfy2008.map'; 
%do i=1 %to &amp;amp;cnt; 
libname xml&amp;amp;i xml "&amp;amp;dir.\&amp;amp;&amp;amp;name&amp;amp;i...xml" xmlmap=sxlemap access=readonly;
proc datasets lib=xml&amp;amp;i; 
run;
proc append base=outfile.detail data= xml&amp;amp;i..detail force; 
run;
libname xml&amp;amp;i; 
clear;
%end;
%let rc=%sysfunc(dclose(&amp;amp;did)); 
%mend test;
%test(h:\xml temp);&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Apr 2018 11:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-different-XML-files-to-a-combined-SAS-dataset/m-p/455892#M284332</guid>
      <dc:creator>katariasarthak</dc:creator>
      <dc:date>2018-04-20T11:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Convert different XML files to a combined SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Convert-different-XML-files-to-a-combined-SAS-dataset/m-p/455894#M284333</link>
      <description>&lt;P&gt;Well, there's not much to add to the error message:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;XML describe error: XML table does not exist DETAIL.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The table DETAIL does not exist in the XML file.&amp;nbsp; I have nothing further to go on.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If I was you I would start by importing one XML file, with some simple datastep code.&amp;nbsp; 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.&amp;nbsp; All you need to start is:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;libname myxml xml "h:\xml temp\file1.xml" xmlmap=sxlemap access=readonly;&lt;BR /&gt;data want;&lt;BR /&gt;  set myxml.detail;   /* &amp;lt;-- note here it is stating detail */&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;You will note that a table "detail" is to be looked for in the XML file (in your original code):&lt;/P&gt;
&lt;PRE&gt;proc append base=outfile.detail data= xml&amp;amp;i..detail force; 
run;&lt;/PRE&gt;
&lt;P&gt;I expect that you just copy and pasted that, but you need to replace detail with the table in your XML.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One you have that running then a simple loop around it and you can import multiple files.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 11:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Convert-different-XML-files-to-a-combined-SAS-dataset/m-p/455894#M284333</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-04-20T11:31:36Z</dc:date>
    </item>
  </channel>
</rss>

