<?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: Proc Import CSV from multiple sources in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200835#M37530</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need first to create a directory listing with the files you're after. Let's say it's always the first of the month then a DIR command as below would work:&lt;/P&gt;&lt;P&gt;dir /b/s C:\temp\datefolders\*my_stuff.csv&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You then use this dos command in a pipe, eg. as below, to create a directory listing&lt;/P&gt;&lt;P&gt;filename dirlist pipe 'dir /b/s C:\temp\datefolders\01*my_stuff.csv';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are many examples in this community how to create a directory listing and then process the files found. A search will bring them up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 13 Jul 2015 23:41:30 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2015-07-13T23:41:30Z</dc:date>
    <item>
      <title>Proc Import CSV from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200831#M37526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have this situation. I have to pull data for about six months, and the data is in csv but the way they are saved, it is not that straightforward. There is a folder for each date, and in them there are several csv files. CSV filenames start with date and some extension. I need one of these files going back about six months. I found macros which import CSVs from folders which are named this way, but this macro was pulling all the files, not just one,so kind of using wildcard. Any help will be greatly appreciated. I can probably write a macro to do this, but it will take me longer than I have.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks much,&lt;/P&gt;&lt;P&gt;- CD&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 00:04:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200831#M37526</guid>
      <dc:creator>cd2011</dc:creator>
      <dc:date>2015-07-13T00:04:51Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import CSV from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200832#M37527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Create a list of file names. If you know the structure of the naming system create a dataset with the names and then use CALL EXECUTE to import the files. If you don't know the data set names ahead of time, use an OS command to recursively list all the files and then filter that out to generate the list you need. Then use a basic macro to import.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Or use the filename option and a data step import - assuming all files have the same structure. &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If you post more details you can get more help.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 01:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200832#M37527</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-07-13T01:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import CSV from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200833#M37528</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, clarify what you have, how you identify each file.&amp;nbsp; Its pretty simple once you have the logic, say for instance you want all files which have XYZ in the filename:&lt;/P&gt;&lt;P&gt;filename tmp pipe 'dir "c:\the_directory" /b /s';&lt;/P&gt;&lt;P&gt;data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length buffer $2000;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; infile tmp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; input buffer $;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if index(buffer,"csv") &amp;gt; 0 and index(buffer,"XYZ") &amp;gt; 0 then call execute('data '||strip(scan(buffer,1,'.'))||'; infile ...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; '); /* add in your import code after infile */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 08:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200833#M37528</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-13T08:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import CSV from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200834#M37529</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So my folders are named by dates and the CSVs have similar naming.&lt;/P&gt;&lt;P&gt;Eg: "C:\...\01012015\01012015_my_stuff.csv",&lt;/P&gt;&lt;P&gt;"C:\...\01022015\01022015_my_stuff.csv" &lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;. &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;"C:\...\07142015\07142015_my_stuff.csv" &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;CD&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 21:53:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200834#M37529</guid>
      <dc:creator>cd2011</dc:creator>
      <dc:date>2015-07-13T21:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import CSV from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200835#M37530</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need first to create a directory listing with the files you're after. Let's say it's always the first of the month then a DIR command as below would work:&lt;/P&gt;&lt;P&gt;dir /b/s C:\temp\datefolders\*my_stuff.csv&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You then use this dos command in a pipe, eg. as below, to create a directory listing&lt;/P&gt;&lt;P&gt;filename dirlist pipe 'dir /b/s C:\temp\datefolders\01*my_stuff.csv';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are many examples in this community how to create a directory listing and then process the files found. A search will bring them up.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jul 2015 23:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200835#M37530</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2015-07-13T23:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import CSV from multiple sources</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200836#M37531</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There's a few examples on the web. Check the sample on the link bellow:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;windows:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://support.sas.com/kb/24/707.html" title="http://support.sas.com/kb/24/707.html"&gt;24707 - Reading multiple files with PROC IMPORT&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;linux:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/24/addl/fusion24707_1_unixsamp157.txt" title="http://support.sas.com/kb/24/addl/fusion24707_1_unixsamp157.txt"&gt;http://support.sas.com/kb/24/addl/fusion24707_1_unixsamp157.txt&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 11:30:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Import-CSV-from-multiple-sources/m-p/200836#M37531</guid>
      <dc:creator>BrunoSilva</dc:creator>
      <dc:date>2015-07-14T11:30:05Z</dc:date>
    </item>
  </channel>
</rss>

