<?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 a a .csv file to a SAS dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436201#M108484</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can try&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;&lt;P&gt;%let file=&lt;SPAN&gt;DATROCF&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;%put &amp;amp;file;&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;mac&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%do i=&lt;STRONG&gt;1&lt;/STRONG&gt; %to &lt;STRONG&gt;5&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;proc import datafile="path\&amp;amp;&amp;amp;file.&amp;amp;i..csv" out=test&amp;amp;i&lt;/P&gt;&lt;P&gt;dbms=csv&lt;/P&gt;&lt;P&gt;replace ;&lt;/P&gt;&lt;P&gt;/*sheet="sheet1";*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%mac;&lt;/P&gt;</description>
    <pubDate>Mon, 12 Feb 2018 12:12:46 GMT</pubDate>
    <dc:creator>srinath3111</dc:creator>
    <dc:date>2018-02-12T12:12:46Z</dc:date>
    <item>
      <title>Importing a a .csv file to a SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436162#M108463</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My requirement is to import data from a number of .csv files into a SAS data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I am using the following code to do the same. The .csv files&amp;nbsp;( 5 in number namely DATROCF1,DATROCF2,DATROCF3,DATROCF4,DATROCF5)&amp;nbsp;)&amp;nbsp;have been placed in the shared path. The issue which I am facing is that. the dataset 'DATRDOCF' has data only from the 5th file in the path. and not from all the files.&lt;/P&gt;&lt;P&gt;Can you please help me out.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let subdir=F:\pol\New folder\;
filename dir "&amp;amp;subdir.*.csv ";
data new;
length filename fname $ 200;
infile dir eof=last filename=fname;
input ;
last: filename=fname;
run;
proc sort data=new nodupkey;
by filename;
run;
data null;
set new;
call symputx(cats('filename',_n_),filename);
call symputx(cats('dsn',_n_),compress(scan(filename,-2,'\.'), ,'ka'));
call symputx('nobs',_n_);
run;
%put &amp;amp;nobs.;
%macro import;
%do i=1 %to &amp;amp;nobs;
proc import datafile="&amp;amp;&amp;amp;filename&amp;amp;i" out=&amp;amp;&amp;amp;dsn&amp;amp;i dbms=csv ;
getnames=yes;
run;
%end;
%mend import;
　
%import&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 12 Feb 2018 07:41:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436162#M108463</guid>
      <dc:creator>Sreelekha</dc:creator>
      <dc:date>2018-02-12T07:41:20Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a a .csv file to a SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436173#M108470</link>
      <description>&lt;P&gt;Use the search functionality on here or google to search for "import multiple csv files", you will find hundreds of posts.&amp;nbsp; Firstly you do not need all that code as:&lt;/P&gt;
&lt;PRE&gt;data want;
  infile "f:/pol/newfolder/*.csv";
 ...
run;&lt;/PRE&gt;
&lt;P&gt;Is the way to import multiple csv files.&amp;nbsp; Avoid putting them in subfolders and this will make your life easier.&amp;nbsp; Also note to avoid spaces and special characters in path names.&lt;/P&gt;
&lt;P&gt;If you want to continue your route then you will need to post full code and log as datrdocf is not shown in this code, only:&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;dsn&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;i&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I assume that you are overwriting datrdocf each time which is why you only end up with the last one, so what you need to do is to append the newly imported data to the previous lot each time except for the first iteration maybe something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 09:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436173#M108470</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-12T09:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a a .csv file to a SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436201#M108484</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can try&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;&lt;P&gt;%let file=&lt;SPAN&gt;DATROCF&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;%put &amp;amp;file;&lt;/P&gt;&lt;P&gt;options mprint;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&amp;nbsp; &lt;STRONG&gt;&lt;EM&gt;mac&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%do i=&lt;STRONG&gt;1&lt;/STRONG&gt; %to &lt;STRONG&gt;5&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;proc import datafile="path\&amp;amp;&amp;amp;file.&amp;amp;i..csv" out=test&amp;amp;i&lt;/P&gt;&lt;P&gt;dbms=csv&lt;/P&gt;&lt;P&gt;replace ;&lt;/P&gt;&lt;P&gt;/*sheet="sheet1";*/&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;%mac;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Feb 2018 12:12:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436201#M108484</guid>
      <dc:creator>srinath3111</dc:creator>
      <dc:date>2018-02-12T12:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: Importing a a .csv file to a SAS dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436663#M108632</link>
      <description>&lt;P&gt;Thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 12:22:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-a-a-csv-file-to-a-SAS-dataset/m-p/436663#M108632</guid>
      <dc:creator>Sreelekha</dc:creator>
      <dc:date>2018-02-13T12:22:36Z</dc:date>
    </item>
  </channel>
</rss>

