Hi:
Well, there's always cut and paste. Seriously though, there are a few different methods you could use. For example, you could write a SAS macro program to detect all the SAS datasets in a certain folder and then automate building a SET statement to concatenate all the files into one SAS data set. Or you could go for a simpler macro program to just type the names of the files for you, as long as the names fall into a pattern that you can automate.
The SAS Macro facility is like a typewriter -- the only difference is that instead of you typing on a keyboard, you write a program and tell the macro facility what kind of code to write for you, and send to the compiler when you invoke it. For example, let's make 4 files, named fil1, fil2, fil3, fil4:
[pre]
** make 4 data files;
data fil1 fil2 fil3 fil4;
x=1; y=2; z=3;
output fil1;
x+2; y+2; z+2;
output fil2;
x+3; y+3; z+3;
output fil3;
x+4; y+4; z+4;
output fil4;
run;
[/pre]
Now, let's say you want to combine the files together in the following ways:
[pre]
data newfile;
set fil1 fil2 fil3 fil4;
run;
** or;
data newfile;
set fil2 fil3 fil4;
run;
** or ;
data newfile;
set fil1 fil2 fil3;
run;
[/pre]
Now we have some working SAS code, but it's sort of a pain to keep typing the data set names over and over -- imagine if you had 100 data sets. The only piece of the code that really needs to change is the list of names of the file after the SET statement. So, how about a macro program that will just build the list of data set names for you:
[pre]
%macro makename(dsn=, start=, stop=);
%do i = &start %to &stop;
&dsn.&i
%end;
%mend makename;
[/pre]
This is just the definition -- it doesn't DO anything until it's invoked. So where would you invoke it?
[pre]
** Now use the macro program to get all 4 files;
options mprint symbolgen;
data newfile1;
set %makename(dsn=fil, start=1, stop=4);
run;
ods listing;
proc print data=newfile1;
title "newfile1";
run;
[/pre]
Or, another way to invoke it would be to use this SET statement:
[pre]
set %makename(dsn=fil, start=2, stop=4);
[/pre]
In this example, the macro variable &DSN will hold the text string FIL and the
%DO loop will iterate from the &START value to the &STOP value.
So the value of &I will increment for each iteration through the loop. The place where the data set name gets generate is between the %DO and the %END...the first time (in the first invocation) through the loop, &DSN will resolve to FIL and &I will resolve to 1 so the macro will type FIL1 for you. Then the next time through the loop, then DSN will still be FIL and &I will be 2 and so the macro will type FIL2, etc, etc.
With the debugging macro options MPRINT and SYMBOLGEN turned on, you can see how the macro variable references resolve by reviewing the generated statements in the SAS Log.
For more help, you can read the SAS Macro Facility documentation which is quite good. Or look for macro program examples on the Tech Support site. Or look for SUGI and SGF papers about SAS Macro programming, like this one:
http://www2.sas.com/proceedings/sugi28/056-28.pdf
For help with a particular macro coding question, Tech Support is always happy to help.
cynthia