<?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 (hundreds at a time) in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534465#M6335</link>
    <description>&lt;P&gt;So what does that tell you?&amp;nbsp; It tells me, that in the directory&amp;nbsp;&lt;SPAN&gt;h:\Practice\PARI, there are no files with the extension .xml.&amp;nbsp; Please supply the real path so that the process can find your xml files.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 11 Feb 2019 14:23:28 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2019-02-11T14:23:28Z</dc:date>
    <item>
      <title>Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533921#M6245</link>
      <description>&lt;P&gt;I know there are some posts about this but I have tried everything and nothing is working so I am getting pretty desperate. I am trying to import all XML files into one SAS dataset. I do not have much experience with this, and I am just starting to get comfortable with macros, so I might need a little extra help on how to tweak code. So far I have been able to successfully import one XML file using this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename datafile 'h:\Practice\PARI\test-20181002-170338-230.xml';&lt;BR /&gt;filename mapfile 'h:\Practice\PARI\XML\test-20181002-170338-230.map';&lt;BR /&gt;libname datafile xmlv2 xmlmap=mapfile automap=replace;&lt;/P&gt;&lt;P&gt;proc copy in=datafile out=work; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This one XML file creates 7 SAS datasets in the work library. I will need to import hundreds of these files, as they come from a medical device company. Then I will need to put all of this information into one working dataset. Does anyone have any idea on how to import all of these files? Also in a way that won't leave me with hundreds of datasets in the work library?&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, 08 Feb 2019 14:22:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533921#M6245</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-02-08T14:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533944#M6247</link>
      <description>&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;%macro imp_xml (fname=,mapname=);
&lt;BR /&gt;  /* This is your original code, I have just replaced the file and map name as parameters */
  filename datafile 'h:\Practice\PARI\&amp;amp;fname.';
  filename mapfile 'h:\Practice\PARI\XML\&amp;amp;mapname.';
  libname datafile xmlv2 xmlmap=mapfile automap=replace;

  proc copy in=datafile out=work; 
  run;
  
  filename datafile clear;
  filename mapfile clear;
  libname datafile clear;

%mend imp_xml;
 
/* Clean work so that we can append all datasets created */
proc datasets lib=work memtype=data kill nolist;
run;
&lt;BR /&gt;/* This is a pipe from your Operating system, it is the same as doing a directory listing&lt;BR /&gt;   from the command prompt.  It will feedback all the filenames with the extension xml&lt;BR /&gt;   in the folder given */
filename inlist pipe 'dir "h:/Practice/PARI/*.xml" /b';
&lt;BR /&gt;/* I replace the _null_ part here, you can look at dirlist dataset in work to see what is read&lt;BR /&gt;   in from the directory listing */
data dirlist;
  length buff mfile $200;
  infile inlist;
  input buff $;&lt;BR /&gt;  mfile=tranwrd(lowcase(buff),".xml",".map");&lt;BR /&gt;/* The next step creates one macro call for every filename returned by the directory listing&lt;BR /&gt;   from the command prompt */
  call execute(cats('%macro imp_xml (fname=',buff,',
                                     mapname=',mfile,');'));
run;&lt;BR /&gt;&lt;BR /&gt;filename inlist clear;&lt;BR /&gt;&lt;BR /&gt;/* Combine all the datasets in work */&lt;BR /&gt;data _null_;&lt;BR /&gt;  set sashelp.vtable (where=(libname="WORK"));&lt;BR /&gt;/* These next steps will generate firstly one dataset called want, then from there on in&lt;BR /&gt;   one proc append for every dataset in the work library */&lt;BR /&gt;  if _n_=1 then call execute(cats('data want; set ',strip(memname),';run;'));&lt;BR /&gt;  else call execute(cats('proc append base=want append=',strip(memname),' force;run;'));&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;/* Remove all files except the final one */&lt;BR /&gt;proc datasets lib=work memtype=data kill nolist;&lt;BR /&gt;  save want;&lt;BR /&gt;run;
&lt;/PRE&gt;
&lt;P&gt;Note not tested!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 16:05:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533944#M6247</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-08T16:05:33Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533950#M6248</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for the quick response. This is what I got from the log:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;256&lt;BR /&gt;257 %macro imp_xml (fname=,mapname=);&lt;BR /&gt;258&lt;BR /&gt;259 filename datafile 'h:\Practice\PARI\&amp;amp;fname.';&lt;BR /&gt;260 filename mapfile 'h:\Practice\PARI\XML\&amp;amp;mapname.';&lt;BR /&gt;261 libname datafile xmlv2 xmlmap=mapfile automap=replace;&lt;BR /&gt;262&lt;BR /&gt;263 proc copy in=datafile out=work;&lt;BR /&gt;264 run;&lt;BR /&gt;265&lt;BR /&gt;266 filename datafile clear;&lt;BR /&gt;267 filename mapfile clear;&lt;BR /&gt;268 libname datafile clear;&lt;BR /&gt;269&lt;BR /&gt;270 %mend imp_xml;&lt;BR /&gt;271&lt;BR /&gt;272 /* Clean work so that we can append all datasets created */&lt;BR /&gt;273 proc datasets libname=work memtype=data kill nolist;&lt;BR /&gt;-------&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;WARNING 1-322: Assuming the symbol LIB was misspelled as libname.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;NOTE: Deleting WORK.BASE_DATA (memtype=DATA).&lt;BR /&gt;NOTE: Deleting WORK.DRUG_NAME (memtype=DATA).&lt;BR /&gt;NOTE: Deleting WORK.DRUG_NAMES (memtype=DATA).&lt;BR /&gt;NOTE: Deleting WORK.FILESINFOLDER (memtype=DATA).&lt;BR /&gt;NOTE: Deleting WORK.INHALATIONDATA (memtype=DATA).&lt;BR /&gt;NOTE: Deleting WORK.INHALATION_DATA (memtype=DATA).&lt;BR /&gt;NOTE: Deleting WORK.MT_STUDYINHALATIONDATA01 (memtype=DATA).&lt;BR /&gt;274 run;&lt;/P&gt;&lt;P&gt;275&lt;BR /&gt;276 filename inlist pipe 'dir "h:/PracticePARI/*.xml" /b';&lt;BR /&gt;277&lt;/P&gt;&lt;P&gt;NOTE: PROCEDURE DATASETS used (Total process time):&lt;BR /&gt;real time 0.06 seconds&lt;BR /&gt;cpu time 0.04 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;278 data _null_;&lt;BR /&gt;279 length buff mfile $200;&lt;BR /&gt;280 infile inlist;&lt;BR /&gt;281 input buff $;&lt;BR /&gt;282 mfile=tranwrd(lowcase(buff),".xml",".map");&lt;BR /&gt;283 call execute(cats('%macro imp_xml (fname=',buff,',&lt;BR /&gt;284 mapname=',mfile,');'));&lt;BR /&gt;285 run;&lt;/P&gt;&lt;P&gt;NOTE: The infile INLIST is:&lt;BR /&gt;Unnamed Pipe Access Device,&lt;BR /&gt;PROCESS=dir "h:/PracticePARI/*.xml" /b,RECFM=V,&lt;BR /&gt;LRECL=32767&lt;/P&gt;&lt;P&gt;Stderr output:&lt;BR /&gt;File Not Found&lt;BR /&gt;NOTE: 0 records were read from the infile INLIST.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.07 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;286&lt;BR /&gt;287 filename inlist clear;&lt;BR /&gt;NOTE: Fileref INLIST has been deassigned.&lt;BR /&gt;288&lt;BR /&gt;289 /* Combine all the datasets in work */&lt;BR /&gt;290 data _null_;&lt;BR /&gt;291 set sashelp.vtable (where=(libname="WORK"));&lt;BR /&gt;292 if _n_=1 then call execute('data want; set ',strip(memname),';run;');&lt;BR /&gt;-------&lt;BR /&gt;253&lt;BR /&gt;293 else call execute('proc append base=want append=',strip(memname),' force;run;');&lt;BR /&gt;-------&lt;BR /&gt;253&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 253-185: The EXECUTE subroutine call has too many arguments.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;294 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.10 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;295&lt;BR /&gt;296 /* Remove all files except the final one */&lt;BR /&gt;297 proc datasets lib=work memtype=data kill nolist;&lt;BR /&gt;298 save want;&lt;BR /&gt;299 run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;ERROR: The file WORK.WANT (memtype=DATA) was not found, but appears on a SAVE statement.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;NOTE: Statements not processed because of errors noted above.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 15:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533950#M6248</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-02-08T15:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533963#M6250</link>
      <description>&lt;P&gt;I have updated the code originally provided to cover these errors.&amp;nbsp; Do note I am not going to do this for you, you need to do some debugging, learning what that code does and adapting it to your needs.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 15:31:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533963#M6250</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-08T15:31:38Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533979#M6252</link>
      <description>&lt;P&gt;That didn't work either... I don't expect you to write it for me but I do not understand what you are doing in this code and therefore I don't know how to start with the debugging.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code isn't reading in any observations at all and I don't know why that is...&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 15:55:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533979#M6252</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-02-08T15:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533986#M6253</link>
      <description>&lt;P&gt;I have added some comments to the code.&amp;nbsp; Open a command prompt (its on windows start or just search for com), type in the pipe command:&lt;/P&gt;
&lt;PRE&gt;dir "h:/Practice/PARI/*.xml"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;The output from that is fed back to your dataset for processing, it should list all the XML files in the directory:&lt;/P&gt;
&lt;P&gt;h:/Practice/PARI/&lt;/P&gt;
&lt;P&gt;That is the directory you provided.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 16:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533986#M6253</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-08T16:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533993#M6254</link>
      <description>&lt;P&gt;Thank you for your comments. So that directory is where all of the XML files are stored, but for whatever reason it is still reading in 0 observations:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;NOTE: The infile INLIST is:&lt;BR /&gt;Unnamed Pipe Access Device,&lt;BR /&gt;PROCESS=dir "h:/Practice/PARI/*.xml" /b,&lt;BR /&gt;RECFM=V,LRECL=32767&lt;/P&gt;&lt;P&gt;Stderr output:&lt;BR /&gt;File Not Found&lt;BR /&gt;NOTE: 0 records were read from the infile INLIST.&lt;BR /&gt;NOTE: The data set WORK.DIRLIST has 0 observations and 2 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.08 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;258&lt;BR /&gt;259 filename inlist clear;&lt;BR /&gt;NOTE: Fileref INLIST has been deassigned.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 16:19:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/533993#M6254</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-02-08T16:19:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534407#M6321</link>
      <description>&lt;P&gt;And per the previous post, what does it show when you type the dir command at the command prompt?&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 09:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534407#M6321</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-11T09:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534440#M6331</link>
      <description>&lt;P&gt;Microsoft Windows [Version 10.0.17134.523]&lt;BR /&gt;(c) 2018 Microsoft Corporation. All rights reserved.&lt;/P&gt;&lt;P&gt;H:\&amp;gt;h:/Practice/PARI/&lt;BR /&gt;'h:/Practice/PARI/' is not recognized as an internal or external command,&lt;BR /&gt;operable program or batch file.&lt;/P&gt;&lt;P&gt;H:\&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 13:09:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534440#M6331</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-02-11T13:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534445#M6333</link>
      <description>&lt;P&gt;The line you should enter at the command prompt is exactly the same as it is run:&lt;/P&gt;
&lt;PRE&gt;dir "h:/Practice/PARI/*.xml"&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 13:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534445#M6333</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-11T13:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534446#M6334</link>
      <description>&lt;P&gt;Ok. When I did that it said:&lt;/P&gt;&lt;P&gt;Directory of h:\Practice\PARI&lt;/P&gt;&lt;P&gt;File Not Found&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 13:22:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534446#M6334</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-02-11T13:22:10Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534465#M6335</link>
      <description>&lt;P&gt;So what does that tell you?&amp;nbsp; It tells me, that in the directory&amp;nbsp;&lt;SPAN&gt;h:\Practice\PARI, there are no files with the extension .xml.&amp;nbsp; Please supply the real path so that the process can find your xml files.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 14:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534465#M6335</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-11T14:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534474#M6337</link>
      <description>&lt;P&gt;That is the folder in which all of the XML files are held though? I specifically made the folder on my H drive in a sub folder practice then another folder called PARI which I dragged and dropped all of the xml files to.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 14:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534474#M6337</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-02-11T14:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534483#M6341</link>
      <description>&lt;P&gt;Are you using SAS University Edition?&amp;nbsp; If so then please follow the guidance for how to get files onto the virtual image.&amp;nbsp; You cannot access local files directly as a mapped drive, you have to copy them to myfolders.&lt;/P&gt;
&lt;P&gt;If not, please state what software you are using, and show a picture of the explorer folder containing the files in question, showing the exact path.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 15:05:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534483#M6341</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-11T15:05:27Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534487#M6342</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27047iAB1B6C1EBCAC358A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am using SAS 9.4&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 15:10:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534487#M6342</guid>
      <dc:creator>fordcr2</dc:creator>
      <dc:date>2019-02-11T15:10:33Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple XML files (hundreds at a time)</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534498#M6343</link>
      <description>&lt;P&gt;Mmm, its odd that the wildcard doesn't work.&amp;nbsp; Anyways, just change to:&lt;/P&gt;
&lt;PRE&gt;%macro imp_xml (fname=,mapname=);

  /* This is your original code, I have just replaced the file and map name as parameters */
  filename datafile 'h:\Practice\PARI\&amp;amp;fname.';
  filename mapfile 'h:\Practice\PARI\XML\&amp;amp;mapname.';
  libname datafile xmlv2 xmlmap=mapfile automap=replace;

  proc copy in=datafile out=work; 
  run;
  
  filename datafile clear;
  filename mapfile clear;
  libname datafile clear;

%mend imp_xml;
 
/* Clean work so that we can append all datasets created */
proc datasets lib=work memtype=data kill nolist;
run;

/* This is a pipe from your Operating system, it is the same as doing a directory listing
   from the command prompt.  It will feedback all the filenames with the extension xml
   in the folder given */
filename inlist pipe 'dir "h:/Practice/PARI" /b';

/* I replace the _null_ part here, you can look at dirlist dataset in work to see what is read
   in from the directory listing */
data dirlist;
  length buff mfile $200;
  infile inlist;
  input buff $;
  mfile=tranwrd(lowcase(buff),".xml",".map");
/* The next step creates one macro call for every filename returned by the directory listing
   from the command prompt */
  call execute(cats('%macro imp_xml (fname=',buff,',
                                     mapname=',mfile,');'));
run;

filename inlist clear;

/* Combine all the datasets in work */
data _null_;
  set sashelp.vtable (where=(libname="WORK"));
/* These next steps will generate firstly one dataset called want, then from there on in
   one proc append for every dataset in the work library */
  if _n_=1 then call execute(cats('data want; set ',strip(memname),';run;'));
  else call execute(cats('proc append base=want append=',strip(memname),' force;run;'));
run;

/* Remove all files except the final one */
proc datasets lib=work memtype=data kill nolist;
  save want;
run;&lt;/PRE&gt;
&lt;P&gt;So just take the /*.xml&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Off the pipe and it should list all the files in that directory.&lt;/P&gt;</description>
      <pubDate>Mon, 11 Feb 2019 15:24:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Importing-multiple-XML-files-hundreds-at-a-time/m-p/534498#M6343</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-02-11T15:24:29Z</dc:date>
    </item>
  </channel>
</rss>

