title: Appending csv files in SAS
body: <p>I have a bunch of csv files. Each has data from a different period:</p>
  
  <pre><code>filename file1 'JAN2011_PRICE.csv';
  filename file2 'FEB2011_PRICE.csv';
  ...
  </code></pre>
  
  <p>Do I need to manually create intermediate datasets and then append them all together? Is there a better way of doing this?</p>
  
  <p><strong>SOLUTION</strong></p>
  
  <p>From the documentation it is preferable to use:</p>
  
  <pre><code>data allcsv;
         length fileloc myinfile $ 300;
         input fileloc $ ; /* read instream data       */
  
        /* The INFILE statement closes the current file 
           and opens a new one if FILELOC changes value 
           when INFILE executes                        */
         infile my filevar=fileloc 
                filename=myinfile end=done dlm=','; 
  
        /* DONE set to 1 when last input record read  */
         do while(not done);
        /* Read all input records from the currently  */
        /* opened input file                          */
           input col1 col2 col3 ...;
           output;
         end;
         put 'Finished reading ' myinfile=; 
  datalines;
  path-to-file1
  path-to-file2
  ...
  run;
  </code></pre>