<?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: Read and Merge multiple csv files with same first rows in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764366#M242107</link>
    <description>&lt;P&gt;You can use a filename statement with wildcards to select the files and on the infile statement you need to make use of the following properties:&lt;BR /&gt;&lt;STRONG&gt;firstobs=2&lt;/STRONG&gt; (to start reading data from the second line)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;eov&lt;/STRONG&gt;&amp;nbsp;&lt;SPAN&gt;specifies a variable that SAS sets to 1 when the first record in a file in a series of concatenated files is read&lt;/SPAN&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below is a solution to your problem (it assumes you have 3 variables a,b,c and they are all numeric):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let csvFolder= &amp;lt;Path to the directory containing the csv files&amp;gt;;&lt;BR /&gt;filename ttt "&amp;amp;csvFolder.\q*_all.csv" ;

data CSVIN;
	infile ttt truncover firstobs=2 dlm=',' dsd eov=_eov ;
	input @ ;/*Start read line and hold*/

	if _eov then do ; /*If if 1st row of file */
		_eov = 0 ;/* EOV = 1 after first row of next file and needs to be reset to 0 */
		delete ; /*delete the 1st row of each file because it is the header*/
	end ;

	input a b c;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 26 Aug 2021 22:33:51 GMT</pubDate>
    <dc:creator>a_SAS_sin</dc:creator>
    <dc:date>2021-08-26T22:33:51Z</dc:date>
    <item>
      <title>Read and Merge multiple csv files with same first rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764347#M242099</link>
      <description>&lt;P&gt;Hi. I have multiple csv files named as:&lt;/P&gt;&lt;P&gt;q1_2012_all&lt;/P&gt;&lt;P&gt;q2_2012_all&lt;/P&gt;&lt;P&gt;q3_2012_all&lt;/P&gt;&lt;P&gt;q4_2012_all&lt;/P&gt;&lt;P&gt;q1_2013_all&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;q2_2021_all&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know how to read them and combine them?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 21:19:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764347#M242099</guid>
      <dc:creator>JoannaQQQ</dc:creator>
      <dc:date>2021-08-26T21:19:30Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Merge multiple csv files with same first rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764356#M242106</link>
      <description>&lt;P&gt;A recent similar request&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Programming/macro-for-load-in-multiple-files-csv/m-p/763795" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/macro-for-load-in-multiple-files-csv/m-p/763795&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The key bit here is getting the names of the files into a data set with the Path information.&lt;/P&gt;
&lt;P&gt;The example uses SAS on Demand which starts the users path with ~ . If running in a windows system start with a drive letter.&lt;/P&gt;
&lt;P&gt;If you are running on a server version of SAS then the files have to be in a location that the Server can see with the path which would likely not be the case of reading files on your computer unless a network share of some sort has been set up.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 21:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764356#M242106</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-08-26T21:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Merge multiple csv files with same first rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764366#M242107</link>
      <description>&lt;P&gt;You can use a filename statement with wildcards to select the files and on the infile statement you need to make use of the following properties:&lt;BR /&gt;&lt;STRONG&gt;firstobs=2&lt;/STRONG&gt; (to start reading data from the second line)&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;eov&lt;/STRONG&gt;&amp;nbsp;&lt;SPAN&gt;specifies a variable that SAS sets to 1 when the first record in a file in a series of concatenated files is read&lt;/SPAN&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below is a solution to your problem (it assumes you have 3 variables a,b,c and they are all numeric):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let csvFolder= &amp;lt;Path to the directory containing the csv files&amp;gt;;&lt;BR /&gt;filename ttt "&amp;amp;csvFolder.\q*_all.csv" ;

data CSVIN;
	infile ttt truncover firstobs=2 dlm=',' dsd eov=_eov ;
	input @ ;/*Start read line and hold*/

	if _eov then do ; /*If if 1st row of file */
		_eov = 0 ;/* EOV = 1 after first row of next file and needs to be reset to 0 */
		delete ; /*delete the 1st row of each file because it is the header*/
	end ;

	input a b c;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 26 Aug 2021 22:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764366#M242107</guid>
      <dc:creator>a_SAS_sin</dc:creator>
      <dc:date>2021-08-26T22:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Merge multiple csv files with same first rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764387#M242120</link>
      <description>&lt;P&gt;The option firstobs is not useful when reading multiple files with one infile statement, because the option does not work per file.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Aug 2021 04:45:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764387#M242120</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-08-27T04:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Merge multiple csv files with same first rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764414#M242132</link>
      <description>You need the firstobs option to remove the header of the first file.</description>
      <pubDate>Fri, 27 Aug 2021 07:43:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764414#M242132</guid>
      <dc:creator>a_SAS_sin</dc:creator>
      <dc:date>2021-08-27T07:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: Read and Merge multiple csv files with same first rows</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764466#M242153</link>
      <description>&lt;PRE&gt;%let path=c:\temp ;

data _null_;
rc=filename('x',"&amp;amp;path");
did=dopen('x');
do i=1 to dnum(did);
 fname=dread(did,i);
 if scan(fname,-1,'.')='csv' then call execute(catt("proc import datafile='&amp;amp;path\",fname,
 "' out=",scan(fname,1,'.')," dbms=csv replace;run;"));
end;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Aug 2021 14:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Read-and-Merge-multiple-csv-files-with-same-first-rows/m-p/764466#M242153</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-08-27T14:11:00Z</dc:date>
    </item>
  </channel>
</rss>

