<?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: Can you create generic code to loop &amp;amp; combine only the files listed in a text doc? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255415#M268896</link>
    <description>&lt;P&gt;It should...I don't quite follow how it's not working for you.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Mar 2016 02:32:51 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-03-09T02:32:51Z</dc:date>
    <item>
      <title>Can you create generic code to loop &amp; combine only the files listed in a text doc?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255376#M268893</link>
      <description>&lt;P&gt;Background:&amp;nbsp; We're trying to create a sas&amp;nbsp;program (9.4)&amp;nbsp;that combines multiple data .txt files (all same format) from one folder to create one large&amp;nbsp;file.&amp;nbsp; The problem is not all .txt files in the folder&amp;nbsp;should be included and the names differ too much that you can't fix it by specifying something like *ais.txt instead of *.txt.&amp;nbsp; We also want to reduce the number of changes needed in the program to run the program for other years.&amp;nbsp; The program below goes to a folder and lists the directory of all .txt files which are then all combined.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Question:&amp;nbsp; Is there a way to use .txt file that lists by line the specific names of the files you want to be combined like this:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;R:\AIS\Final Files\2015\ais1.txt &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;R:\AIS\Final Files\2015\ais2.txt &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;R:\AIS\Final Files\2015\wierdname1.txt&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;and the program calls up that file (ais2015directory.txt) and loops through to combine the files listed?&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or is&amp;nbsp;there a better or easier way to do this&amp;nbsp;where we can still use the same program for different years without making a lot of changes each year?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does any of this make sense?&amp;nbsp; Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;CODE class=" language-sas"&gt;
/*!!!!!Change Lib Directory*/

libname AIS15 'R:\AIS\Final Files\2015'; run;

/*!!! Change Directory*/

%let dirname = R:\AIS\Submissions\2015;

filename DIRLIST pipe "dir /B ""&amp;amp;dirname""\*.txt"; **the 2 sets of double quotes are needed here to allow for spaces in our file name;

data dirlist ;

length fname $256; 

infile dirlist length=reclen ;

input fname $varying256. reclen ;

run;




data AIS_auto (drop=fname);

length field1 $1. field2 $4. field3 $8. ;

set dirlist;

 filepath = "&amp;amp;dirname\"||fname;

infile dummy filevar = filepath length=reclen delimiter=',' end=done DSD MISSOVER lrecl=32767 firstobs=2;;

do while(not done);

myfilename = filepath;

input field1 field2 field3;

output;

end;

run;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Mar 2016 21:51:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255376#M268893</guid>
      <dc:creator>BeckyBell2355</dc:creator>
      <dc:date>2016-03-08T21:51:51Z</dc:date>
    </item>
    <item>
      <title>Re: Can you create generic code to loop &amp; combine only the files listed in a text doc?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255390#M268894</link>
      <description>&lt;P&gt;I've noticed you're using the FILEVAR option - can you &amp;nbsp;filter the list that gets fed to the input process?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2016 22:38:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255390#M268894</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-08T22:38:24Z</dc:date>
    </item>
    <item>
      <title>Re: Can you create generic code to loop &amp; combine only the files listed in a text doc?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255414#M268895</link>
      <description>&lt;P&gt;I think that's what I thought the seperate file which lists each of the files to use would do.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The desire is to reduce the amount of changes in&amp;nbsp;the coding since the file names and locations&amp;nbsp;are different from year to year (and there's 11-13 different files to combine), so we can still use the same&amp;nbsp;program for old and new years.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 02:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255414#M268895</guid>
      <dc:creator>BeckyBell2355</dc:creator>
      <dc:date>2016-03-09T02:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can you create generic code to loop &amp; combine only the files listed in a text doc?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255415#M268896</link>
      <description>&lt;P&gt;It should...I don't quite follow how it's not working for you.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 02:32:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255415#M268896</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-03-09T02:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Can you create generic code to loop &amp; combine only the files listed in a text doc?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255539#M268897</link>
      <description>&lt;P&gt;Could you please show me example code of what you mean? &amp;nbsp;I'm still learning SAS as I go... &amp;nbsp;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 09 Mar 2016 14:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-you-create-generic-code-to-loop-amp-combine-only-the-files/m-p/255539#M268897</guid>
      <dc:creator>BeckyBell2355</dc:creator>
      <dc:date>2016-03-09T14:50:07Z</dc:date>
    </item>
  </channel>
</rss>

