<?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 multiple CSV files in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331220#M21983</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* create three csvs;

dm "dexport sashelp.cars'd:\csv\cars.csv' replace";
dm "dexport sashelp.class'd:\csv\class.csv' replace";
dm "dexport sashelp.classfit'd:\csv\classfit.csv' replace";

* create three sas datsets;

%symdel fyl; * just in case it exists;
data _null_;
  do csv="classfit","class","cars";
     fyl=catx(' ',"dm 'dimport",cats('"d:\csv\',csv,'.csv"'),csv,"replace';");
     call execute(fyl);
  end;
run;quit;

NOTE: WORK.CLASSFIT data set was successfully created.
NOTE: The data set WORK.CLASSFIT has 19 observations and 10 variables.

NOTE: WORK.CLASS data set was successfully created.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.

NOTE: WORK.CARS data set was successfully created.
NOTE: The data set WORK.CARS has 428 observations and 15 variables.




&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Feb 2017 16:24:04 GMT</pubDate>
    <dc:creator>rogerjdeangelis</dc:creator>
    <dc:date>2017-02-09T16:24:04Z</dc:date>
    <item>
      <title>Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331123#M21970</link>
      <description>&lt;P&gt;Dear experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Me, the newbe, has created a macro to read in some csv files. It works but I think the code can be smarter since now I do this manually for something like 30 files which are all located in the same folder. Here an example for reading in 5 files.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;the code in SAS EG:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; imp(infile);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;PROC IMPORT OUT=&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;SAS_TMP.&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;infile &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;datafile = &lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"\\DWCPMCP\Data\01_INPUTDOCS\&amp;amp;infile..csv"&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;DBMS=csv REPLACE;&lt;/P&gt;&lt;P&gt;GETNAMES=YES;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;datarow=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;6&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; imp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(IL_V450)&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(IL_V500)&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(IL_V100)&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(IL_V350)&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;imp&lt;/I&gt;&lt;/STRONG&gt;(IL_V600)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My is, can I make this code less manually intensive? There are more files coming in. Can I import the whole folder in one time instead of typing them out?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advice.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/13418i4252943424ECCE28/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="CSV files.PNG" title="CSV files.PNG" /&gt;</description>
      <pubDate>Thu, 09 Feb 2017 11:34:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331123#M21970</guid>
      <dc:creator>RensMeerman</dc:creator>
      <dc:date>2017-02-09T11:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331132#M21971</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its a good idea to do a search before posting a question. &amp;nbsp;There are literaly hundreds of posts on this topic:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/forums/searchpage/tab/message?q=import+multiple+csv+files" target="_blank"&gt;https://communities.sas.com/t5/forums/searchpage/tab/message?q=import+multiple+csv+files&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't need macro, you can do it in a datastep and use wildcards:&lt;/P&gt;
&lt;P&gt;infile "&amp;lt;pathtocsvs&amp;gt;\*.csv";&lt;/P&gt;
&lt;P&gt;All you have to remember is proper CSV files have headers, so you need to jump one row per file.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 11:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331132#M21971</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-02-09T11:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331151#M21976</link>
      <description>&lt;P&gt;I would recommend the methods here. You may need some modification to start at line 6.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that proc import guesses types so as the number of files gets larger it's more likely that you'll get inconsistent data types, ie a VAR is char in one dataset and numeric in another.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using method above requires you explicitly specify it, once.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2017 14:00:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331151#M21976</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-02-09T14:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331154#M21977</link>
      <description>&lt;P&gt;And best of all the doc has exactly your example&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/mcrolref/69726/HTML/default/viewer.htm#n0ctmldxf23ixtn1kqsoh5bsgmg8.htm" target="_blank"&gt;Example 1: Import All CSV Files That Exist within a Directory&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an annotated example that explains each step of the code.&amp;nbsp; Sample use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%drive(c:\temp,csv)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Sep 2018 18:55:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331154#M21977</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-09-25T18:55:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331220#M21983</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* create three csvs;

dm "dexport sashelp.cars'd:\csv\cars.csv' replace";
dm "dexport sashelp.class'd:\csv\class.csv' replace";
dm "dexport sashelp.classfit'd:\csv\classfit.csv' replace";

* create three sas datsets;

%symdel fyl; * just in case it exists;
data _null_;
  do csv="classfit","class","cars";
     fyl=catx(' ',"dm 'dimport",cats('"d:\csv\',csv,'.csv"'),csv,"replace';");
     call execute(fyl);
  end;
run;quit;

NOTE: WORK.CLASSFIT data set was successfully created.
NOTE: The data set WORK.CLASSFIT has 19 observations and 10 variables.

NOTE: WORK.CLASS data set was successfully created.
NOTE: The data set WORK.CLASS has 19 observations and 5 variables.

NOTE: WORK.CARS data set was successfully created.
NOTE: The data set WORK.CARS has 428 observations and 15 variables.




&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Feb 2017 16:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/331220#M21983</guid>
      <dc:creator>rogerjdeangelis</dc:creator>
      <dc:date>2017-02-09T16:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447497#M28934</link>
      <description>Hi,&lt;BR /&gt;I have a question:&lt;BR /&gt;What should be changed in the code to select specific files from the folder?</description>
      <pubDate>Wed, 21 Mar 2018 16:58:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447497#M28934</guid>
      <dc:creator>Uzi</dc:creator>
      <dc:date>2018-03-21T16:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447503#M28937</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200385"&gt;@Uzi&lt;/a&gt;&amp;nbsp;That depends on what 'specific files' means.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If they have a naming convention or all the same extension those would be different approaches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200385"&gt;@Uzi&lt;/a&gt; wrote:&lt;BR /&gt;Hi,&lt;BR /&gt;I have a question:&lt;BR /&gt;What should be changed in the code to select specific files from the folder?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Mar 2018 17:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447503#M28937</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-21T17:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447658#M28952</link>
      <description>Hey,&lt;BR /&gt;&lt;BR /&gt;sorry for the delay and the lack of detail.&lt;BR /&gt;explanation:&lt;BR /&gt;I split the run into several computers to shorten the running time.&lt;BR /&gt;The result is multiple .csv files in the local&amp;nbsp; of multiple computers.&lt;BR /&gt;I have to group them back into one work file.&lt;BR /&gt;I can determine the names according to my convenience.&lt;BR /&gt;&lt;BR /&gt;The problem:&lt;BR /&gt;There are several runs in each of the folders and I have to choose each time a specific run.&lt;BR /&gt;This means that each time I have to see the file names before importing and then choose who to import and group according to the conditions I set.&lt;BR /&gt;Before that I used Excel to consolidate the files and I could use a "flag"\"pointer" for the run I wanted to consolidate.&lt;BR /&gt;Hope I've been able to explain myself properly.&lt;BR /&gt;Thank you in advance for your help!&lt;BR /&gt;</description>
      <pubDate>Thu, 22 Mar 2018 02:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447658#M28952</guid>
      <dc:creator>Uzi</dc:creator>
      <dc:date>2018-03-22T02:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447661#M28953</link>
      <description>Small correction:&lt;BR /&gt;The name of the files will apply the year, the quarter, and the group from which it came</description>
      <pubDate>Thu, 22 Mar 2018 03:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447661#M28953</guid>
      <dc:creator>Uzi</dc:creator>
      <dc:date>2018-03-22T03:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447668#M28954</link>
      <description>&lt;P&gt;I'm not understanding your question. I would suggest starting your own thread and explaining in detail..&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 03:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447668#M28954</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-22T03:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447692#M28956</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/200385"&gt;@Uzi&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Please start a new post with your question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's sometimes better to tell us what you have and what you need - and only then tell us what you've already tried. You've got a lot of experienced people in this forum and it's sometimes worth to give the big picture as then you might get solution approaches you haven't even thought about.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Mar 2018 08:20:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447692#M28956</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2018-03-22T08:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Import multiple CSV files</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447743#M28959</link>
      <description>Thank you very much Patrick I will.</description>
      <pubDate>Thu, 22 Mar 2018 12:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Proc-Import-multiple-CSV-files/m-p/447743#M28959</guid>
      <dc:creator>Uzi</dc:creator>
      <dc:date>2018-03-22T12:38:11Z</dc:date>
    </item>
  </channel>
</rss>

