<?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 multiple CSV files data to single CSV file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833437#M329475</link>
    <description>&lt;P&gt;Do want a SAS data set or a CSV file?&lt;/P&gt;
&lt;P&gt;A data step can read multiple CSV files into a single SAS data set IF the CSV files all have the same structure.&lt;/P&gt;</description>
    <pubDate>Wed, 14 Sep 2022 20:35:41 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-09-14T20:35:41Z</dc:date>
    <item>
      <title>Importing multiple CSV files data to single CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833429#M329471</link>
      <description>&lt;P&gt;Hello All, I am using SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a 101 CSV files in the directory. I want to combine all csv files into one single CSV file /one dataset .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Everyday one csv file will add into the same directory and I need to combine all csv files into one single csv file again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me with the sas code&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 20:06:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833429#M329471</guid>
      <dc:creator>tysonsri</dc:creator>
      <dc:date>2022-09-14T20:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple CSV files data to single CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833437#M329475</link>
      <description>&lt;P&gt;Do want a SAS data set or a CSV file?&lt;/P&gt;
&lt;P&gt;A data step can read multiple CSV files into a single SAS data set IF the CSV files all have the same structure.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 20:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833437#M329475</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-09-14T20:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple CSV files data to single CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833442#M329476</link>
      <description>I want a single sas dataset.&lt;BR /&gt;All 101 csv files are in same structure.&lt;BR /&gt;&lt;BR /&gt;How do we do that in a sas?&lt;BR /&gt;comibe all 101 .csv files to one data set&lt;BR /&gt;</description>
      <pubDate>Wed, 14 Sep 2022 20:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833442#M329476</guid>
      <dc:creator>tysonsri</dc:creator>
      <dc:date>2022-09-14T20:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple CSV files data to single CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833443#M329477</link>
      <description>&lt;P&gt;Do you have code to read a single CSV file? As a data step?&lt;/P&gt;
&lt;P&gt;When you combine all the data do you need to add any information about which file it came from?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a rough idea on how to read all files into a single SAS data set in one step:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-do-I-write-a-macro-to-import-multiple-text-files-that-have/ta-p/223627&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 20:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833443#M329477</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-14T20:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: Importing multiple CSV files data to single CSV file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833447#M329478</link>
      <description>&lt;P&gt;If all of the CSV files have the same structure and are either all of the CSV files in that folder or all that follow a simple pattern then just use a single data step with a wildcard, * , in the filename.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    length fname $256;
    infile "\\my directory\*.csv" dsd truncover filename=fname;
    input @;
    if fname ne lag(fname) then delete;
    length firstvar 8 secondvar $40 lastvar 8;
    informat lastvar date.;
    format lastvar date9.;
    input firstvar -- lastvar;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the files are really large you might need to work harder by keeping track of which files you already read so you know which ones are new,&amp;nbsp; but if the files are not that big then it is probably just easier to read the all each time.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Sep 2022 20:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Importing-multiple-CSV-files-data-to-single-CSV-file/m-p/833447#M329478</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-09-14T20:57:24Z</dc:date>
    </item>
  </channel>
</rss>

