<?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: Append several csv files with many variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Append-several-csv-files-with-many-variables/m-p/282507#M57424</link>
    <description>&lt;P&gt;Although writing out the full INPUT statement may seem 'inefficient', it is really best practice because it gives you full control. Also, you may be able to generate the INPUT statement if you have the field names available in electronic form.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The lazy, er, efficient approach will be to use PROC IMPORT as 'CSV' is one of the available DBMS options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this sends you on the right solution path.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Jul 2016 18:23:52 GMT</pubDate>
    <dc:creator>sh0e</dc:creator>
    <dc:date>2016-07-06T18:23:52Z</dc:date>
    <item>
      <title>Append several csv files with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-several-csv-files-with-many-variables/m-p/282503#M57420</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem seems simple but I am quite new to SAS so I would appreciate some help.&lt;/P&gt;&lt;P&gt;I need to create a dataset from several CSV files that appear in a directory. It seems that it is easy to use a command data-infile-input to do that. However, the problem is that I have around 90 variables (columns) so writing each one of those next to the input statement seems quite inefficient.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any other way to append all these csv files and keep all the variables available?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jul 2016 18:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-several-csv-files-with-many-variables/m-p/282503#M57420</guid>
      <dc:creator>aekara</dc:creator>
      <dc:date>2016-07-06T18:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Append several csv files with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-several-csv-files-with-many-variables/m-p/282507#M57424</link>
      <description>&lt;P&gt;Although writing out the full INPUT statement may seem 'inefficient', it is really best practice because it gives you full control. Also, you may be able to generate the INPUT statement if you have the field names available in electronic form.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The lazy, er, efficient approach will be to use PROC IMPORT as 'CSV' is one of the available DBMS options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this sends you on the right solution path.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jul 2016 18:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-several-csv-files-with-many-variables/m-p/282507#M57424</guid>
      <dc:creator>sh0e</dc:creator>
      <dc:date>2016-07-06T18:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: Append several csv files with many variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Append-several-csv-files-with-many-variables/m-p/282512#M57428</link>
      <description>&lt;P&gt;If you have metadata on the files (note that CSV files have no place to store metadata, at best the CSV might have column names in the first row) then you can easily use it to generate the code to read the files.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have no information on what is in the files&amp;nbsp;you can use PROC IMPORT and SAS will make an intellegent guess as to what type of fields you have basd on the data in the file and generate a data step to read the file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the files are all in the same format you can read them all&amp;nbsp;in a single data step if you want. &amp;nbsp;If you don't care what the variable names are you can just name them something like VAR1 to VAR90.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
   infile 'my_directory/*.csv' dsd firstobs=2 truncover eov=eov;
   input @;
   if eov then input;
   eov=0;

   length var1-var90 $100 ;
   input var1-var90 ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jul 2016 18:41:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Append-several-csv-files-with-many-variables/m-p/282512#M57428</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2016-07-06T18:41:55Z</dc:date>
    </item>
  </channel>
</rss>

