<?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: Reading in large csv files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767897#M243508</link>
    <description>&lt;P&gt;INFILE is definitely more efficient, especially since you know the schema for these files. And if all files share the same layout, you can do this in a single DATA step. See &lt;A href="https://blogs.sas.com/content/sasdummy/2018/10/09/read-multiple-text-files/" target="_self"&gt;this article for how to read multiple text files at once&lt;/A&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 15 Sep 2021 13:34:46 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2021-09-15T13:34:46Z</dc:date>
    <item>
      <title>Reading in large csv files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767896#M243507</link>
      <description>&lt;P&gt;Folks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 13 individual csv files which in total come to nearly 40GB in size. I'm looking for tips in terms of getting efficiencies in reading them to SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Originally I had code which would list the 13 csv files and their location and a macro which would cycle through each one and use proc import to read them in and output them to as a SAS file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I'm wondering is it best to this or to use an infile statement as I know the position of all the columns and their lengths.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My macro is handy as it uses guessing rows = max but I imagine with such large files now it will take ages to run.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Perhaps an infile method would be better?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 13:27:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767896#M243507</guid>
      <dc:creator>Sean_OConnor</dc:creator>
      <dc:date>2021-09-15T13:27:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in large csv files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767897#M243508</link>
      <description>&lt;P&gt;INFILE is definitely more efficient, especially since you know the schema for these files. And if all files share the same layout, you can do this in a single DATA step. See &lt;A href="https://blogs.sas.com/content/sasdummy/2018/10/09/read-multiple-text-files/" target="_self"&gt;this article for how to read multiple text files at once&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 13:34:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767897#M243508</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2021-09-15T13:34:46Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in large csv files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767902#M243509</link>
      <description>&lt;P&gt;Furthermore, you can zip that CSV files to save some space and than use the "INFILE ZIP" to read directly from the zipped file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 13:59:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767902#M243509</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2021-09-15T13:59:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reading in large csv files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767922#M243512</link>
      <description>&lt;P&gt;Is the list of files static?&amp;nbsp; Perhaps just create a fileref that points to all of the files and read from that.&lt;/P&gt;
&lt;P&gt;If you need to skip header rows test for when you are starting a new file.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename all
('/dir/file1.csv'
 '/dir/file2.csv'
...
 '/dir/file13.csv'
);
data want;
  length fname $256 ;
  infile all dsd truncover filename=fname;
  input @;
  if fname ne lag(fname) then input;
  * code to define variables and input a record ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or it you just want to read all of the files whose names follow a simple pattern then use a * wildcard in the physical filename in the INFILE statement.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  length fname $256 ;
  infile '/dir/file*.csv' dsd truncover filename=fname;
  input @;
  if fname ne lag(fname) then input;
  * code to define variables and input a record ;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Sep 2021 15:35:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reading-in-large-csv-files/m-p/767922#M243512</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-09-15T15:35:42Z</dc:date>
    </item>
  </channel>
</rss>

