<?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: Multiple text files into one Sas dataset using macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13757#M1682</link>
    <description>OK, well this is my code I have so far:&lt;BR /&gt;
&lt;BR /&gt;
%MACRO workdata;&lt;BR /&gt;
%DO a=1 %TO 314;&lt;BR /&gt;
DATA hclr&amp;amp;a;&lt;BR /&gt;
INFILE 'C:users\work\documents\work\hclr&amp;amp;a..txt';&lt;BR /&gt;
INFORMAT ..... ;&lt;BR /&gt;
INPUT ....;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC SORT DATA=hclr&amp;amp;a;&lt;BR /&gt;
	BY .....;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
%END;&lt;BR /&gt;
%MEND workdata;&lt;BR /&gt;
&lt;BR /&gt;
%workdata;&lt;BR /&gt;
&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
The error is that it says the files can't be found but I thought the hclr&amp;amp;a..txt code should have continously replace &amp;amp;a with the numbers 1 through 314?? This code I thought would work to create 314 data sets that I could later merge.  Anyone see any problems with this macro?  I am using the right infile statement because it does work when I replace &amp;amp;a with a number.  Thanks for any help.</description>
    <pubDate>Thu, 02 Apr 2009 14:20:59 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2009-04-02T14:20:59Z</dc:date>
    <item>
      <title>Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13748#M1673</link>
      <description>Basically I am trying to create a dataset that contains a little over 300 text files.  The file names range from hclr1.txt to hclr314.txt.  They all have the same variables and are aligned neatly in columns.  Is there a way to read in all these files using a do loop and macro to read all files rather than making an infile statement from each and merging later??  Any help would be appreciated. Thanks</description>
      <pubDate>Tue, 31 Mar 2009 19:47:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13748#M1673</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-31T19:47:16Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13749#M1674</link>
      <description>Some of these txt files contain the variable day with monday wednesday friday and others contain monday tuesday wednesday thursday and friday.  I am not sure how this will affect the data when it is merged??</description>
      <pubDate>Tue, 31 Mar 2009 20:09:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13749#M1674</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-31T20:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13750#M1675</link>
      <description>Yes you may. Just use the loop macro variable in the filename. After reading the file , just PROC APPEND it to a common table.&lt;BR /&gt;
&lt;BR /&gt;
I'm not sure why you are concerned about the day variable. It will just a ordinary column in the result table...?&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Tue, 31 Mar 2009 20:17:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13750#M1675</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-03-31T20:17:32Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13751#M1676</link>
      <description>I am going to end up sorting by day of th week.  I tried merging the data (I just tried 3 files at the moment) and when I merged the files with Monday-Friday with the Monday Wednesday Friday it seems to have messed up.&lt;BR /&gt;
&lt;BR /&gt;
An example of my data is:&lt;BR /&gt;
&lt;BR /&gt;
Monday 1 14 3 79 14.07&lt;BR /&gt;
Wednesday .....&lt;BR /&gt;
Friday .....&lt;BR /&gt;
&lt;BR /&gt;
merged with:&lt;BR /&gt;
&lt;BR /&gt;
Monday .....&lt;BR /&gt;
Tuesday .....&lt;BR /&gt;
Wednesday ....&lt;BR /&gt;
Thursday ....&lt;BR /&gt;
Friday .....&lt;BR /&gt;
&lt;BR /&gt;
The problem is that when I merge a dataset that does not contain a Tuesday, all the data from wednesday moves to tuesday and friday is left blank.  &lt;BR /&gt;
&lt;BR /&gt;
As for the macro, I have little knowledge or expierience working with them so really have no clue on the specific language needed to run properly.&lt;BR /&gt;
&lt;BR /&gt;
Once again thanks for any help.</description>
      <pubDate>Tue, 31 Mar 2009 20:36:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13751#M1676</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-31T20:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13752#M1677</link>
      <description>If the files are all structured reasonably consistent, at least where you can code one (or more as needed) INPUT statements, why not use the FILENAME and generate the list of files (if each is not too large to process as a single input stream) so that the files are treated as a logical concatenation with a DATA step.  The list of files can easily be generated by a MACRO %DO %END loop, incrementing you file-suffix count.  Here is the FILENAME syntax, abbreviated:&lt;BR /&gt;
&lt;BR /&gt;
FILENAME INDATA ("file1.txt" "file2.txt" "file3.txt");&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Tue, 31 Mar 2009 20:42:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13752#M1677</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-03-31T20:42:39Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13753#M1678</link>
      <description>Hi:&lt;BR /&gt;
  Just to clarify...there is a difference between MERGING datasets and CONCATENATING or APPENDING datasets.&lt;BR /&gt;
 &lt;BR /&gt;
  Here's an example....you have a dataset for every month: WORK.JAN, WORK.FEB, WORK.MAR, etc and the data looks like this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
file WORK.JAN&lt;BR /&gt;
day  sale month&lt;BR /&gt;
 01   101 01&lt;BR /&gt;
 02   102 01&lt;BR /&gt;
 03   103 01&lt;BR /&gt;
                                    &lt;BR /&gt;
file WORK.FEB&lt;BR /&gt;
day  sale month&lt;BR /&gt;
 01   201 02&lt;BR /&gt;
 02   202 02&lt;BR /&gt;
 03   203 02&lt;BR /&gt;
                                              &lt;BR /&gt;
file WORK.MAR&lt;BR /&gt;
day  sale month&lt;BR /&gt;
 01   301 03&lt;BR /&gt;
 02   302 03&lt;BR /&gt;
 03   303 03&lt;BR /&gt;
[/pre]&lt;BR /&gt;
           &lt;BR /&gt;
and you want to "stack" or "append" all the files together so that you have an entire year. That syntax would be:&lt;BR /&gt;
[pre]&lt;BR /&gt;
data allyear;&lt;BR /&gt;
  set work.jan work.feb work.mar work.apr work.may work.jun&lt;BR /&gt;
      work.jul work.aug work.sep work.oct work.nov work.dec;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                                                 &lt;BR /&gt;
(or you could use PROC APPEND or PROC SQL,) but for now, let's stick with a data step program. The output in WORK.ALLYEAR would now look like this (only a few obs shown for each month):&lt;BR /&gt;
[pre]&lt;BR /&gt;
file WORK.ALLYEAR&lt;BR /&gt;
day  sale month&lt;BR /&gt;
 01   101 01&lt;BR /&gt;
 02   102 01&lt;BR /&gt;
 03   103 01&lt;BR /&gt;
 01   201 02&lt;BR /&gt;
 02   202 02&lt;BR /&gt;
 03   203 02&lt;BR /&gt;
 01   301 03&lt;BR /&gt;
 02   302 03&lt;BR /&gt;
 03   303 03&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                      &lt;BR /&gt;
Note how the data are "stacked" one month on top of the next month and so on. This would be concatenating or appending.&lt;BR /&gt;
                            &lt;BR /&gt;
                                    &lt;BR /&gt;
Or, you could join the data "horizontally". Consider this data for every month (only a few obs are shown) the day variable identifies the day of the month the sale variable for each month, for ease of the example, is named jansale, febsale, marsale, etc:&lt;BR /&gt;
                   &lt;BR /&gt;
[pre]&lt;BR /&gt;
file WORK.JAN&lt;BR /&gt;
day jansale&lt;BR /&gt;
 01   101&lt;BR /&gt;
 02   102&lt;BR /&gt;
 03   103&lt;BR /&gt;
                       &lt;BR /&gt;
file WORK.FEB&lt;BR /&gt;
day febsale&lt;BR /&gt;
 01   201&lt;BR /&gt;
 02   202&lt;BR /&gt;
 03   203&lt;BR /&gt;
                            &lt;BR /&gt;
file WORK.MAR&lt;BR /&gt;
day marsale&lt;BR /&gt;
 01   301&lt;BR /&gt;
 02   302&lt;BR /&gt;
 03   303&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                      &lt;BR /&gt;
If the data were joined horizontally, you would get this:&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
file WORK.ALLYEAR&lt;BR /&gt;
day jansale febsale marsale&lt;BR /&gt;
01      101     201     301&lt;BR /&gt;
02      102     202     302&lt;BR /&gt;
03      103     203     303&lt;BR /&gt;
.... more observations ....&lt;BR /&gt;
25      125     225     325&lt;BR /&gt;
26      126     226     326&lt;BR /&gt;
27      127     227     327&lt;BR /&gt;
28      128     228     328&lt;BR /&gt;
29      129       .     329&lt;BR /&gt;
30      130       .     330&lt;BR /&gt;
31      131       .     331&lt;BR /&gt;
                 &lt;BR /&gt;
[/pre]&lt;BR /&gt;
                   &lt;BR /&gt;
Note how the end of the month shows missing values for days 29, 30 and 31 for Feb (because Feb did not have any sales on those days).&lt;BR /&gt;
 &lt;BR /&gt;
The code that created the above output is shown below:&lt;BR /&gt;
[pre]&lt;BR /&gt;
                  &lt;BR /&gt;
data allyear;   &lt;BR /&gt;
  merge jan(in=injan)&lt;BR /&gt;
        feb(in=infeb)&lt;BR /&gt;
        mar(in=inmar);&lt;BR /&gt;
  by day;&lt;BR /&gt;
run;&lt;BR /&gt;
           &lt;BR /&gt;
proc print data=allyear;&lt;BR /&gt;
  title 'after merge';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
                    &lt;BR /&gt;
If you are appending, then not having Tuesday in one file should not make a difference. If you are merging, using a data step, then you should merge with a BY statement and if you are joining with PROC SQL, then you have to be careful with the type of join you code so you get the right combination of rows and columns in the output file. &lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Tue, 31 Mar 2009 21:23:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13753#M1678</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-03-31T21:23:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13754#M1679</link>
      <description>Thank you, that was very helpful.&lt;BR /&gt;
&lt;BR /&gt;
I am still confused on how to import the 300 txt files though.  I currently have a macro in which I have n=0 and then n=&amp;amp;n + 1 where i have my file names hclr&amp;amp;n.txt, I don't know if this is possible and it doesn't seem to be working.  I just need it to read in my files and each has the same variable name and each file is just one number higher than the last.</description>
      <pubDate>Tue, 31 Mar 2009 22:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13754#M1679</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-03-31T22:51:12Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13755#M1680</link>
      <description>I suggest you look at the documentation for the INFILE statement.  You will want to pay particular attention to the FILEVAR option.  You will need read about the INPUT statement. See the following thread for and example I posted using INFILE and FILEVAR etc.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;A href="http://support.sas.com/forums/thread.jspa?messageID=18256䝐" target="_blank"&gt;http://support.sas.com/forums/thread.jspa?messageID=18256䝐&lt;/A&gt;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Tue, 31 Mar 2009 23:21:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13755#M1680</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-03-31T23:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13756#M1681</link>
      <description>It seems that you need to acquire some basic skills in macro programming. I suggest that you take a class in this subject. It's available as a e-course:&lt;BR /&gt;
&lt;BR /&gt;
&lt;A href="http://www.sas.com/apps/elearning/elearning_courses.jsp?cat=SAS+Advanced+Programming" target="_blank"&gt;http://www.sas.com/apps/elearning/elearning_courses.jsp?cat=SAS+Advanced+Programming&lt;/A&gt;&lt;BR /&gt;
&lt;BR /&gt;
or as a traditional instructor lead one at your nearest SAS office.&lt;BR /&gt;
&lt;BR /&gt;
Regards,&lt;BR /&gt;
Linus</description>
      <pubDate>Wed, 01 Apr 2009 06:45:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13756#M1681</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-04-01T06:45:42Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13757#M1682</link>
      <description>OK, well this is my code I have so far:&lt;BR /&gt;
&lt;BR /&gt;
%MACRO workdata;&lt;BR /&gt;
%DO a=1 %TO 314;&lt;BR /&gt;
DATA hclr&amp;amp;a;&lt;BR /&gt;
INFILE 'C:users\work\documents\work\hclr&amp;amp;a..txt';&lt;BR /&gt;
INFORMAT ..... ;&lt;BR /&gt;
INPUT ....;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
PROC SORT DATA=hclr&amp;amp;a;&lt;BR /&gt;
	BY .....;&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
%END;&lt;BR /&gt;
%MEND workdata;&lt;BR /&gt;
&lt;BR /&gt;
%workdata;&lt;BR /&gt;
&lt;BR /&gt;
RUN;&lt;BR /&gt;
&lt;BR /&gt;
The error is that it says the files can't be found but I thought the hclr&amp;amp;a..txt code should have continously replace &amp;amp;a with the numbers 1 through 314?? This code I thought would work to create 314 data sets that I could later merge.  Anyone see any problems with this macro?  I am using the right infile statement because it does work when I replace &amp;amp;a with a number.  Thanks for any help.</description>
      <pubDate>Thu, 02 Apr 2009 14:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13757#M1682</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-02T14:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13758#M1683</link>
      <description>Hi:&lt;BR /&gt;
  Try these 2 title statements and see which one works -- &amp;amp;SYSDATE is an automatic macro variable:&lt;BR /&gt;
[pre]&lt;BR /&gt;
title1 'Run on &amp;amp;sysdate';&lt;BR /&gt;
title2 "Run on &amp;amp;sysdate";&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 02 Apr 2009 14:24:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13758#M1683</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-04-02T14:24:26Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13759#M1684</link>
      <description>Suggest you add the following statement to your program in order to generate as much diagnostic information as possible in your SAS log output - the second statement (or both of them, as preferred) can be commented out when you have a working macro:&lt;BR /&gt;
&lt;BR /&gt;
OPTIONS SOURCE SOURCE2;&lt;BR /&gt;
OPTIONS MACROGEN SYMBOLGEN MLOGIC;&lt;BR /&gt;
&lt;BR /&gt;
The additional SAS compilation information generated will help you self-diagnose the SAS problem, when using macro language.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 02 Apr 2009 15:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13759#M1684</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-02T15:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13760#M1685</link>
      <description>It gave me more information but it still says physical file does not exist.  For some reason it is not replacing the &amp;amp;a..txt with the new number of the do loop.</description>
      <pubDate>Thu, 02 Apr 2009 17:57:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13760#M1685</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-02T17:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13761#M1686</link>
      <description>I figured it out.  It needed " " instead of ' ' around the infile statement. Thanks for all the Help!!</description>
      <pubDate>Thu, 02 Apr 2009 18:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13761#M1686</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-02T18:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13762#M1687</link>
      <description>You should be able to follow the SAS code compilation and generate SAS statements from your macro.  If unable to identify the problem cause, you need to post a reply with your SAS log information (COPY / PASTE) into your reply.  Key information is "where your macro variable is assigned" and "where does SAS resolve the code using the macro variable".  SAS will reveal the macro variable assignments -- obviously the lines must use an ampersand where referenced.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Thu, 02 Apr 2009 18:18:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13762#M1687</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-04-02T18:18:35Z</dc:date>
    </item>
    <item>
      <title>x command and data step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13763#M1688</link>
      <description>I have a similar situation.  The structure of the files is the same, but the file names are random, and over time, more files are added.&lt;BR /&gt;
&lt;BR /&gt;
This program uses the x command to go to Windows and generate a file with the names of all *.csv files in a directory.  Then control comes back to SAS, and the INFILE statement uses the generated file with the FILEVAR option to read and stack the files.  &lt;BR /&gt;
&lt;BR /&gt;
All you need to know to use this method is the directory and filetype.&lt;BR /&gt;
&lt;BR /&gt;
I left the length and input statements as is so you could see the structure.&lt;BR /&gt;
&lt;BR /&gt;
Wendy&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
filename par_files 'D:\yada\my_files.sas' ;&lt;BR /&gt;
x 'cd D:\yada\my_directory' ;&lt;BR /&gt;
x 'del my_files.sas' ;&lt;BR /&gt;
x 'dir *.csv /a-d /B /L &amp;gt; my_files.sas' ;&lt;BR /&gt;
x 'exit' ;&lt;BR /&gt;
&lt;BR /&gt;
DATA PAR_FILES ;&lt;BR /&gt;
&lt;BR /&gt;
LENGTH&lt;BR /&gt;
READFILE   $ 200&lt;BR /&gt;
STATION    $ 20&lt;BR /&gt;
PAR1_      $ 10&lt;BR /&gt;
PAR2_      $ 10&lt;BR /&gt;
PAR3_      $ 10    ;&lt;BR /&gt;
&lt;BR /&gt;
FORMAT SASDATE YYMMDD6.  ;&lt;BR /&gt;
&lt;BR /&gt;
INFILE PAR_FILES ;&lt;BR /&gt;
INPUT READFILE $ ;&lt;BR /&gt;
INFILE FILE FILEVAR=READFILE END=DONE MISSOVER PAD LRECL=900 FIRSTOBS=4 DLM=',' ;&lt;BR /&gt;
DO UNTIL (DONE) ;&lt;BR /&gt;
&lt;BR /&gt;
INPUT&lt;BR /&gt;
STATION  $ SASDATE YYMMDD8. TIME1  REP SET DPTHSTR PAR_K&lt;BR /&gt;
DPTHCOL1   PAR1 PAR1_ $&lt;BR /&gt;
DPTHCOL2   PAR2 PAR2_ $&lt;BR /&gt;
DPTHCOL3   PAR3 PAR3_ $    ;&lt;BR /&gt;
&lt;BR /&gt;
OUTPUT ;&lt;BR /&gt;
END ;&lt;BR /&gt;
&lt;BR /&gt;
RUN ;</description>
      <pubDate>Tue, 07 Apr 2009 15:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13763#M1688</guid>
      <dc:creator>WendyT</dc:creator>
      <dc:date>2009-04-07T15:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13764#M1689</link>
      <description>SASuser01&lt;BR /&gt;
 &lt;BR /&gt;
because you have SAS you have a simple process to load this data.&lt;BR /&gt;
It is a data step.&lt;BR /&gt;
The infile statement (except on ZOS mainframes, which I think is NOT your platform) allow you to define the physical file names with an *, like[pre]      infile '\\path\hclr*.txt' ; [/pre]That takes care of all that macro looping. You need only one infile statement. (keep files with similar names that you do not wish to load, in a different folder). &lt;BR /&gt;
What remains is the code to read your columns. As your files all have the same layout, you need only one set of code to read them.&lt;BR /&gt;
Since you don't describe your text file in detail, I won't offer code to read it.&lt;BR /&gt;
 &lt;BR /&gt;
good Luck&lt;BR /&gt;
 &lt;BR /&gt;
PeterC</description>
      <pubDate>Tue, 07 Apr 2009 21:29:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13764#M1689</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-04-07T21:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiple text files into one Sas dataset using macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13765#M1690</link>
      <description>PeterC-&lt;BR /&gt;
&lt;BR /&gt;
That's a MUCH better solution than mine - I'll give it a try.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for the help!&lt;BR /&gt;
&lt;BR /&gt;
Wendy</description>
      <pubDate>Thu, 09 Apr 2009 17:24:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Multiple-text-files-into-one-Sas-dataset-using-macro/m-p/13765#M1690</guid>
      <dc:creator>WendyT</dc:creator>
      <dc:date>2009-04-09T17:24:35Z</dc:date>
    </item>
  </channel>
</rss>

