顺路贴一个把多个外部数据写到同一个sas数据集的程序:
http://support.sas.com/kb/24/712.html
--------------------------------------------------------------------------------
/* Create external file EXTFILE1 */
data _null_;
file 'c:\temp\extfile1.txt';
put "05JAN2001 6 W12301 1.59 9.54";
put "12JAN2001 3 P01219 2.99 8.97";
put "16JAN2001 1 A00101 3.00 3.00";
put "19JAN2001 3 A00101 3.00 9.00";
put "24JAN2001 2 B90035 2.59 5.18";
run;
/* Create external file EXTFILE2 */
data _null_;
file 'c:\temp\extfile2.txt';
put "02FEB2001 1 P01219 2.99 2.99";
put "05FEB2001 3 A00901 1.99 5.97";
put "07FEB2001 2 C21135 3.00 6.00";
put "14FEB2001 7 B90035 2.59 18.13";
put "20FEB2001 6 A00901 1.99 11.94";
put "27FEB2001 1 W12301 1.59 1.59";
put "27FEB2001 2 C00300 1.00 2.00";
put "28FEB2001 2 B90035 2.59 5.18";
run;
/* Create the external file EXTFILE3 */
data _null_;
file 'c:\temp\extfile3.txt';
put "06MAR2001 4 A00101 3.59 14.36";
put "12MAR2001 2 P01219 2.99 5.98";
put "13MAR2001 2 A00101 3.00 6.00";
put "16MAR2001 3 B90035 2.59 7.77";
put "16MAR2001 1 W99201 5.50 5.50";
put "21MAR2001 3 C30660 2.00 6.00";
put "29MAR2001 5 A00901 1.99 9.95";
run;
/* Path to files to be read are in the DATALINES. */
/* Each file is read in turn with the same INPUT statement. */
/* The END= variable is set to 1 each time the DATA step */
/* comes to the end of a file. */
/* */
/* Read the name of the file to be read from the DATALINES and */
/* store it in FIL2READ. The file is then read in the DO WHILE */
/* loop. At the end of the file, the DO loop ends, control */
/* passes back to the top of DATA step and the process starts */
/* over again until all files have been read. */
/* */
/* The argument "dummy" in the INFILE statement is a place- */
/* holder used in place of a file reference. */
data one;
infile datalines;
/* Ensure fully qualified path will fit in FIL2READ */
length fil2read $40;
/* Input path of file to be read from DATALINES */
input fil2read $;
infile dummy filevar=fil2read end=done;
do while(not done);
/* Input statement for files to be read */
input @1 date date9. @11 quanity item $ price totcost;
output;
end;
datalines;
c:\temp\extfile1.txt
c:\temp\extfile2.txt
c:\temp\extfile3.txt
;
proc print data=one;
run;