<?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: &amp;quot;Example 1: Import All CSV Files That Exist within a Directory&amp;quot; - but I need them proc in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576293#M34300</link>
    <description>I can only see what you've shown and can only respond accordingly.</description>
    <pubDate>Wed, 24 Jul 2019 17:50:10 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-07-24T17:50:10Z</dc:date>
    <item>
      <title>"Example 1: Import All CSV Files That Exist within a Directory" - but I need them processed in order</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576286#M34297</link>
      <description>&lt;P&gt;Hello, I used&amp;nbsp;&lt;A href="http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;http://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&amp;nbsp;to set up my macro and it will happily chug along through my directory full of csvs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately the macro seems to be processing the files in a random order. My csv files overlap in date ranges and I need to make sure they process in order so my code handles overwriting data from older files correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The file names in my directory start with values which increase (but dont increment by any specific amount), with the oldest files having the lowest value as the first six digits:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;138281_longfilename.csv&lt;/P&gt;&lt;P&gt;142049_longfilename.csv&lt;/P&gt;&lt;P&gt;192820_longfilename.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions on how to tell the macro to sort the files in the directory by the first 6 digits?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 17:41:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576286#M34297</guid>
      <dc:creator>clocks212</dc:creator>
      <dc:date>2019-07-24T17:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: "Example 1: Import All CSV Files That Exist within a Directory" - but I need them proc</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576289#M34298</link>
      <description>This particular example only imports each data individually, and creates a unique data set for each file. Not sure how that affects anything in order, the SAS data sets will be each unique to the file and you can then process them further in whatever order you like. Add a step that adds the filename to the data for each data set or to the dataset name if you need that information.</description>
      <pubDate>Wed, 24 Jul 2019 17:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576289#M34298</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-24T17:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: "Example 1: Import All CSV Files That Exist within a Directory" - but I need them proc</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576292#M34299</link>
      <description>&lt;P&gt;I should have added that I replaced this line in the example...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="xis-code"&gt;proc import datafile="&amp;amp;dir\%qsysfunc(dread(&amp;amp;did,&amp;amp;i))" out=dsn&amp;amp;cnt 
           dbms=csv replace;     &lt;/PRE&gt;&lt;P&gt;...with the big block of import and de-dup code which I used to process one file at a time. So the "Example 1..." code no longer imports each file as its own data set but instead imports the file, does some proc sql work comparing, deduping, and union'ing it with my master table.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 17:49:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576292#M34299</guid>
      <dc:creator>clocks212</dc:creator>
      <dc:date>2019-07-24T17:49:37Z</dc:date>
    </item>
    <item>
      <title>Re: "Example 1: Import All CSV Files That Exist within a Directory" - but I need them proc</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576293#M34300</link>
      <description>I can only see what you've shown and can only respond accordingly.</description>
      <pubDate>Wed, 24 Jul 2019 17:50:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576293#M34300</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-07-24T17:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: "Example 1: Import All CSV Files That Exist within a Directory" - but I need them proc</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576295#M34301</link>
      <description>&lt;P&gt;Make the list of names as a dataset.&amp;nbsp; If you are using Windows instead of Unix then adjust the command used to get the list of files appropriately.&amp;nbsp; If you cannot use PIPE then use a data step that uses the method in your posted link. No need to do it in macro code instead of a data step since your macro is already generating other SAS code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let mydir=/folder/where/my/csv/files/live;

data files;
  infile "cd &amp;amp;mydir ; ls *.csv" pipe truncover;
  input filename $256. ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then sort the list into the order you want to process them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=files;
  by filename;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then use the list to generate code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datasets;
  fileno+1;
  set files;
  length memname $32. ;
  memname = cats('csv',fileno);
  call execute(catx(' '
       ,'proc import datafile='
       ,quote(catx('/','&amp;amp;mydir',filename))
       ,'out=',memname,'replace'
       ,'dbms=csv'
       ,';run;'
  ));
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 17:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576295#M34301</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-24T17:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: "Example 1: Import All CSV Files That Exist within a Directory" - but I need them proc</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576299#M34302</link>
      <description>&lt;P&gt;That is exactly what I need. Thank you Tom!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2019 17:53:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/quot-Example-1-Import-All-CSV-Files-That-Exist-within-a/m-p/576299#M34302</guid>
      <dc:creator>clocks212</dc:creator>
      <dc:date>2019-07-24T17:53:27Z</dc:date>
    </item>
  </channel>
</rss>

