<?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 How to import multiple files and concatenate them into one file in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835801#M330458</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I have an issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a directory (C:/mydir/myfiles) where I have many csv files (the number is not constant).&lt;/P&gt;&lt;P&gt;I have to import these files and concatenate them (in no particular order), to get a final csv file. Note that the csv files have identical columns, data types etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;myfile_V1.csv&lt;/P&gt;&lt;P&gt;myfile_V2.csv&lt;/P&gt;&lt;P&gt;myfile_V3.csv&lt;/P&gt;&lt;P&gt;myfile_V4.csv&lt;/P&gt;&lt;P&gt;myfile_V5.csv&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;The final concatenated file should be --&amp;gt; myfile_complete.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how do I proceed with this please in a way that I won't have to manually put the file names every time?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 29 Sep 2022 11:19:42 GMT</pubDate>
    <dc:creator>MILKYLOVE</dc:creator>
    <dc:date>2022-09-29T11:19:42Z</dc:date>
    <item>
      <title>How to import multiple files and concatenate them into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835801#M330458</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I have an issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a directory (C:/mydir/myfiles) where I have many csv files (the number is not constant).&lt;/P&gt;&lt;P&gt;I have to import these files and concatenate them (in no particular order), to get a final csv file. Note that the csv files have identical columns, data types etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;myfile_V1.csv&lt;/P&gt;&lt;P&gt;myfile_V2.csv&lt;/P&gt;&lt;P&gt;myfile_V3.csv&lt;/P&gt;&lt;P&gt;myfile_V4.csv&lt;/P&gt;&lt;P&gt;myfile_V5.csv&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;The final concatenated file should be --&amp;gt; myfile_complete.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how do I proceed with this please in a way that I won't have to manually put the file names every time?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 11:19:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835801#M330458</guid>
      <dc:creator>MILKYLOVE</dc:creator>
      <dc:date>2022-09-29T11:19:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple files and concatenate them into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835804#M330459</link>
      <description>&lt;P&gt;Please have a look at &lt;A href="https://stackoverflow.com/questions/60244/is-there-replacement-for-cat-on-windows" target="_blank"&gt;https://stackoverflow.com/questions/60244/is-there-replacement-for-cat-on-windows&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Or do you need the data in sas? If this is the case, please find of the numerous threads dealing with reading multiple files.Hint the infile-statement allows something like C:/mydir/myfiles/*.csv ...&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 11:20:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835804#M330459</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2022-09-29T11:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple files and concatenate them into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835805#M330460</link>
      <description>&lt;P&gt;I am using Unix, the directory name was just an example. I guess it caused some confusions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My issues is, I don't know how to concatenate all these files into one single file without having to manually input the name of each file every time. (maybe a loop?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For a first step, I have tried to read all the files in the directory and list them:&lt;/P&gt;&lt;PRE&gt;filename myfiles '/sasapp/Liv_Marketing/delsquad/bloc/in';

data filenames (keep=filename);
     dir= dopen('myfiles');

     do file = 1 to dnum(dir);
          filename = dread(dir,file);
          output;
     end;

     rc= dclose(dir);
run;&lt;/PRE&gt;&lt;P&gt;This gives me a list of all the files present in the directory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I need to import all of them and concatenate them into one output file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help&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;</description>
      <pubDate>Thu, 29 Sep 2022 11:26:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835805#M330460</guid>
      <dc:creator>MILKYLOVE</dc:creator>
      <dc:date>2022-09-29T11:26:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to import multiple files and concatenate them into one file</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835806#M330461</link>
      <description>&lt;P&gt;Please pay attention to the hint from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;&amp;nbsp;, you don't need to specifically name each .csv file in your code. You don't even have to read the list of names in the folder.&lt;/P&gt;</description>
      <pubDate>Thu, 29 Sep 2022 11:31:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-import-multiple-files-and-concatenate-them-into-one-file/m-p/835806#M330461</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-09-29T11:31:54Z</dc:date>
    </item>
  </channel>
</rss>

