How can I create external output files from SAS?

advertisement
CREATING SAS EXTERNAL FILES ON UNIX AND ON PC
Sometimes a SAS programmer wants to create files in a text format to be
used as input for other programs (e.g. Fortran, Patran, etc.). The
following two examples create such files. The first program is designed
to run on SAS/UNIX platform and the second program runs on SAS/PC. Each
program creates 2 text files that may be imported and used as input to
other programs. The first program is designed for advanced users and
those familiar with advanced statistical routines. The second program
is simple and easy to follow. Questions regarding SAS and other
engineering and statistical packages should be sent to:
assist@mcsr.olemiss.edu.
In addition to creating the regular output, the following SAS/UNIX
program creates 2 external output files called “out.dat” and “ou.dat”.
The following SAS/UNIX program performs non-linear Least Squares fit
for the given data. A copy of this file can be found on willow at:
/users/local/appl/examples/sasLeastSquares.sas
data nlin;
input pc s
@@ ;
poro=.485 ;
p0=75./pc ;
teta=.485*s ;
cards;
77.8 .946 82.3 .892 87.7 .821 97.8 .719 107.6 .641
123.0 .562 142.6 .492 177.0 .424 207.2 .383
;
proc print;
proc plot; plot teta*pc ;
run;
proc plot ; plot s*pc ;
/* poro=.485 ; */ ;
proc nlin data=nlin ;
p0=75./pc ; teta=.485*s ;
parms b=4. to 20.0 by 2. ;
model teta=p0**b ;
output out=pp1 p=yhat r=resid ;
proc plot data=pp1 (obs=8) ;
plot teta*pc='a' yhat*pc='p' /overlay;
plot resid*s /vref=0 ;
run ;
proc contents data=nlin ; /* verify which data set contains the YHAT
var */
proc contents data=pp1 ;
run;
data _null_ ;
set pp1;
file out;
put teta 1-10 .5 yhat 11-20 .5 poro 21-30 .5 x 31-40;
run;
data _null_ ;
set nlin;
file out2;
put pc s ;
run;
In addition to creating the regular output, the following SAS/PC
program creates 2 external output files called “out.dat” and “ou.dat”.
/* COMMENT AN EXAMPLE OF CREATING AN EXTERNAL FILE, */;
data outprint ;
INPUT A B C D $;
X=(A+B+C)/3.;
FILE OU;
PUT A 1-10 B 11-20 C 21-30 X 31-42 .2 ;
CARDS;
6 2 3 X
3 3 6 Y
9 6 3 Z
100 300 500 W
PROC SORT; BY A; run ;
DATA _NULL_ ;
A=12 ; B=-12. ; C=100. ;
X=(A+B+C)/3.;
FILE OUT;
PUT A 1-10 B 11-20 C 21-30 X 50-57 .4 ;
run
Download