<?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 Re: Importing multiple xml files into 1 sas dataset. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411164#M100507</link>
    <description>&lt;P&gt;Thanks, but both are correct, it doesn´t make any diference.&lt;/P&gt;</description>
    <pubDate>Tue, 07 Nov 2017 13:03:28 GMT</pubDate>
    <dc:creator>vanmon1</dc:creator>
    <dc:date>2017-11-07T13:03:28Z</dc:date>
    <item>
      <title>Importing multiple xml files into 1 sas dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411130#M100494</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have hundreds of xml files to import, all of them with the same layout. I have made the xml map with SAS XML mapper and used code from user called dapstat to import multiple files but it does not read the data eventhough I get a list of the files in the directory.&lt;/P&gt;&lt;P&gt;Could someone please help me in case dapstat is not available? I have already contacted him through his original post. I attach the log.&lt;/P&gt;&lt;P&gt;Or maybe there is a different way?&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename  SXLELIB '\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\sgfxml\02303_20171016070200.xml';
filename  SXLEMAP '\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\SGFXML\siammapV2.map';
libname   SXLELIB xmlv2 xmlmap=SXLEMAP access=READONLY;
 

DATA alerta; SET SXLELIB.alerta; run;



libname siamia 'C:\Users\SAS\Desktop\siamia';
filename DIRLIST pipe 'dir "\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\sgfxml\0*.xml" /b';

data dirlist ;
infile dirlist lrecl=200 truncover;
input file_name $100.;
run;
 
data _null_;
set dirlist end=end;
count+1;
call symputx('read'||put(count,4.-l),cats("\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\SIAM\",file_name));
call symputx('dset'||put(count,4.-l),scan(file_name,1,'.'));
if end then call symputx('max',count);
run;



data siamia.dirlist(rename=(file_name=leadfile));
set dirlist;
order=_n_;run;
 
options mprint symbolgen;
%macro readin;
%do i=1 %to &amp;amp;max;
 
data siamia.leadtarget&amp;amp;i;
set siamia.dirlist;
if &amp;amp;i=order;
run;
 
proc sql noprint;
select leadfile
into :lf
from siamia.leadtarget&amp;amp;i;
quit;
 
filename sgfxml "C:\Users\SAS\Desktop\siamia\&amp;amp;lf";
filename map "\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\SGFXML\siammapV2.map";
libname sgfxml xmlv2 xmlmap=map;
 
data siamia.lead;
set siamia.lead;
run;

%end;
%mend readin;
%readin;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 11:44:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411130#M100494</guid>
      <dc:creator>vanmon1</dc:creator>
      <dc:date>2017-11-07T11:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple xml files into 1 sas dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411143#M100495</link>
      <description>&lt;P&gt;Could you use the following code to import XML automatically ,not need offer XML map.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename x temp;
libname   SXLELIB xmlv2  'c:\temp\temp.xml'  xmlmap=x automap=replace; 
proc copy in=SXLELIB  out=work ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Nov 2017 12:20:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411143#M100495</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-11-07T12:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple xml files into 1 sas dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411145#M100496</link>
      <description>&lt;P&gt;Well to start with you seem to have a network patch for the map:&lt;/P&gt;&lt;TABLE class="crocodoc-doc crocodoc-text mce-item-table" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;"\\tsclient\C\Transferencia de Archivos\IMPORT&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;22 ! TO SAS\SIAM\&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And yet refer to a local c drive for the file:&lt;/P&gt;&lt;PRE class="language-sas lia-code-sample" data-lia-code-lang="sas" data-lia-code-macro="true"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token statement"&gt;filename&lt;/SPAN&gt; sgfxml &lt;SPAN class="token string"&gt;"C:\Users\SAS\Desktop\siamia\&amp;amp;lf"&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;To be honest though your code is so hard to read, consider simplifying it:&lt;/P&gt;&lt;P&gt;&lt;PRE&gt;/* These dont change */
filename  SXLELIB '\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\sgfxml\02303_20171016070200.xml';
filename  SXLEMAP '\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\SGFXML\siammapV2.map';
libname   SXLELIB xmlv2 xmlmap=SXLEMAP access=READONLY;

/* Macro to read in data */
%macro importfile (fn=,ds=);
  filename sgfxml "...";
  filename map "\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\SGFXML\siammapV2.map";
  libname sgfxml xmlv2 xmlmap=map;

  data siamia.lead;
    set siamia.lead;
  run;
%mend importfile;

filename DIRLIST pipe 'dir "\\tsclient\C\Transferencia de Archivos\IMPORT TO SAS\sgfxml\0*.xml" /b';

data _null_;
  infile dirlist lrecl=200 truncover dlm="¬";
  input;
  call execute(cats('%importfile (fn=',_input_,',ds=',scan(_input_,1,"."),');'));
run;&lt;/PRE&gt;&lt;BR data-mce-bogus="1" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 12:34:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411145#M100496</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-07T12:34:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple xml files into 1 sas dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411158#M100503</link>
      <description>&lt;P&gt;Hi, thanks for your reply, but this is only for one file, right?&lt;/P&gt;&lt;P&gt;I need to import hundreds into 1 single sas dataset. thanks&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 12:59:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411158#M100503</guid>
      <dc:creator>vanmon1</dc:creator>
      <dc:date>2017-11-07T12:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple xml files into 1 sas dataset.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411164#M100507</link>
      <description>&lt;P&gt;Thanks, but both are correct, it doesn´t make any diference.&lt;/P&gt;</description>
      <pubDate>Tue, 07 Nov 2017 13:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-xml-files-into-1-sas-dataset/m-p/411164#M100507</guid>
      <dc:creator>vanmon1</dc:creator>
      <dc:date>2017-11-07T13:03:28Z</dc:date>
    </item>
  </channel>
</rss>

