Hi:
Using the FILEVAR option of the FILE statement would make your life MUCH easier. This example is a slightly different example, but shows creating 3 files named:
[pre]
c:\temp\wombat1.txt
c:\temp\wombat2.txt
c:\temp\wombat3.txt
[/pre]
and THEN, in a second program, adds some information to the files created in the first program. The key is the use of the FILEVAR option of the FILE statement.
Documentation:
http://support.sas.com/documentation/cdl/en/lrdict/62618/HTML/default/a000171874.htm
Specifically, my example is a modification of the documentation example #5, entitled, "Dynamically Changing the Current Output File".
cynthia
[pre]
** First method create the files new each time;
data _null_;
length namevar $200;
do i = 1 to 3;
Namevar = cats('c:\temp\','wombat',put(i,1.0),'.txt');
file out filevar=namevar;
put "Twas brillig and the slithy toves";
put i;
end;
run;
** Now Add to the file created above with the MOD option;
** Note that the NAMEVAR needs to be the same in both programs;
** for this to work;
data _null_;
length namevar $200;
do i = 1 to 3;
Namevar = cats('c:\temp\','wombat',put(i,1.0),'.txt');
file out filevar=namevar mod;
put "Did gyre and gimble in the wabe.";
put i;
end;
run;
[/pre]