<?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: Import data from folders in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/431809#M68689</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;　&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; myPath =/myshare/HHFit; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;myPath;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;import&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;= AllState&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;myPath/GA/GA_HHF_STM_ToState_&amp;amp;Currdate_key..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dbms&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=CSV &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;replace&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;1. GA stands for Georgia, one of 19 state folders&amp;nbsp;that appear in myshare/HHFit.&amp;nbsp; Each state has its own folder and .csv file that must be imported every day&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;2.&amp;nbsp;The&amp;nbsp;.csv files need to be read starting at the&amp;nbsp;4th row or firstobs =&amp;nbsp;4.&amp;nbsp; I believe I need a delimiter = '' and missover statement but get errors when I add it&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;3. Since I&amp;nbsp;have 19 folders within the &lt;FONT face="Courier New"&gt;myshare/HHFit&lt;/FONT&gt; share drive is there a way to bring in all 19&amp;nbsp;folder contents or must I use 19 different proc import statements&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;4. When I read in the data I will have only rows of data and columns. Is there a way to also create a shell dataset and populate the results.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ie data allstate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;servicer&lt;BR /&gt;id&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;address&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are all of these files in the same layout (same number of variables, same meaning / type of variable).&lt;/P&gt;
&lt;P&gt;the Proc IMPORT is not for you . Data step code will work better in that all the variables would have the same type and length. You can use Proc import to give you the basic data step code, it will appear in the log and can be copied into the editor and desired changes made. I suggest going through the import wizard to show where to set your first obs option and to use a large value of guessingrows for the first one to have a better chance on identifying the lengths of columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you would replace modify the infile statement and output data set name for each file to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this line in any case should be reviewed:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;myPath/GA/GA_HHF_STM_ToState_&amp;amp;Currdate_key..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;should be&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;"&amp;amp;myPath&lt;FONT size="5"&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;/GA/GA_HHF_STM_ToState_&amp;amp;Currdate_key..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;as forgetting that first dot could create some interesting errors in some useages.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jan 2018 15:30:07 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-01-29T15:30:07Z</dc:date>
    <item>
      <title>Import data from folders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/431632#M68682</link>
      <description>&lt;P&gt;　&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; myPath =/myshare/HHFit; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;myPath;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;import&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;= AllState&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;myPath/GA/GA_HHF_STM_ToState_&amp;amp;Currdate_key..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dbms&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=CSV &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;replace&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;1. GA stands for Georgia, one of 19 state folders&amp;nbsp;that appear in myshare/HHFit.&amp;nbsp; Each state has its own folder and .csv file that must be imported every day&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;2.&amp;nbsp;The&amp;nbsp;.csv files need to be read starting at the&amp;nbsp;4th row or firstobs =&amp;nbsp;4.&amp;nbsp; I believe I need a delimiter = '' and missover statement but get errors when I add it&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;3. Since I&amp;nbsp;have 19 folders within the &lt;FONT face="Courier New"&gt;myshare/HHFit&lt;/FONT&gt; share drive is there a way to bring in all 19&amp;nbsp;folder contents or must I use 19 different proc import statements&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;4. When I read in the data I will have only rows of data and columns. Is there a way to also create a shell dataset and populate the results.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ie data allstate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;servicer&lt;BR /&gt;id&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;address&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 28 Jan 2018 22:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/431632#M68682</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2018-01-28T22:24:37Z</dc:date>
    </item>
    <item>
      <title>Re: Import data from folders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/431648#M68683</link>
      <description>&lt;P&gt;Those are your requirements. What's your question for the forum? What have you tried? What isn't working?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 01:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/431648#M68683</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-29T01:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Import data from folders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/431809#M68689</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;　&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; myPath =/myshare/HHFit; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%put&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;myPath;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;　&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;import&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;= AllState&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;myPath/GA/GA_HHF_STM_ToState_&amp;amp;Currdate_key..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;dbms&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=CSV &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;replace&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;1. GA stands for Georgia, one of 19 state folders&amp;nbsp;that appear in myshare/HHFit.&amp;nbsp; Each state has its own folder and .csv file that must be imported every day&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;2.&amp;nbsp;The&amp;nbsp;.csv files need to be read starting at the&amp;nbsp;4th row or firstobs =&amp;nbsp;4.&amp;nbsp; I believe I need a delimiter = '' and missover statement but get errors when I add it&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;3. Since I&amp;nbsp;have 19 folders within the &lt;FONT face="Courier New"&gt;myshare/HHFit&lt;/FONT&gt; share drive is there a way to bring in all 19&amp;nbsp;folder contents or must I use 19 different proc import statements&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;4. When I read in the data I will have only rows of data and columns. Is there a way to also create a shell dataset and populate the results.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;ie data allstate&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;servicer&lt;BR /&gt;id&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;address&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are all of these files in the same layout (same number of variables, same meaning / type of variable).&lt;/P&gt;
&lt;P&gt;the Proc IMPORT is not for you . Data step code will work better in that all the variables would have the same type and length. You can use Proc import to give you the basic data step code, it will appear in the log and can be copied into the editor and desired changes made. I suggest going through the import wizard to show where to set your first obs option and to use a large value of guessingrows for the first one to have a better chance on identifying the lengths of columns.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you would replace modify the infile statement and output data set name for each file to read.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this line in any case should be reviewed:&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"&amp;amp;myPath/GA/GA_HHF_STM_ToState_&amp;amp;Currdate_key..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;should be&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New"&gt;datafile&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=&lt;/FONT&gt;"&amp;amp;myPath&lt;FONT size="5"&gt;&lt;STRONG&gt;&lt;FONT color="#ff0000"&gt;.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;/GA/GA_HHF_STM_ToState_&amp;amp;Currdate_key..csv"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;as forgetting that first dot could create some interesting errors in some useages.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jan 2018 15:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/431809#M68689</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-29T15:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Import data from folders</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/432114#M68704</link>
      <description>&lt;OL&gt;&lt;LI&gt;I assume that the code you written is working.&lt;/LI&gt;&lt;LI&gt;remove the replace in the code.&lt;/LI&gt;&lt;LI&gt;if you are in linux then use find /pathname/ -name "*.csv" as pipe to get all the CSV file in the parent directory. In your case pathname is&amp;nbsp;&lt;SPAN&gt;/myshare/HHFit&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;Put your code inside a macro like following, I have skipped the part of importing filenames to the DS.&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro ImportCSV(MyFile=);

proc import out= AllState
datafile="&amp;amp;MyFile"
dbms=CSV;
run;

%mend;

Data _null_;
set listofFiles;
command2execute='%ImportCSV('||filenames||');';
call execute(command2execute);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;CODE class=" language-sas"&gt;Please let me know if it works out for you.&lt;/CODE&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Tue, 30 Jan 2018 09:09:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Import-data-from-folders/m-p/432114#M68704</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-01-30T09:09:52Z</dc:date>
    </item>
  </channel>
</rss>

