![]() Chapter Contents |
![]() Previous |
![]() Next |
| SAS Companion for the OS/390 Environment |
| FILE Statement |
As with INFILE, it is possible to alternately access multiple external files. See the example in Reading from Multiple External Files. You cannot write to multiple members of a single PDS at the same time. However, you can write to multiple members of a PDSE at one time.
This section provides a brief overview of FILE statement syntax. For complete information about the FILE statement, see FILE.
The syntax of the FILE statement is
| FILE file-specification < type> <options > <host-options>; |
See Specifying Physical Files for details about different ways of specifying physical-filename.
| Writing to Sequential Data Sets |
filename raw 'myid.raw.datax' disp=old; data _null_; file raw; msgline='write this line'; put msgline; run;
| Writing to Members of PDS or PDSE Data Sets |
/* PDS Example */ filename raw 'myid.raw.data(mem1)' disp=old; data _null_; file raw; put 'write this line'; run;
/* PDSE Example */ filename mypdse 'sales.div1.reg3' disp=shr; data a; x=1; file mypdse(june97); put x; file mypdse(jul97); put x; run;
| Writing to a Printer |
This example uses the FILENAME and FILE statements to route output to a printer.
filename prnt printer sysout=a; data _null_; file prnt; put 'text to write'; run;
| Writing to the Internal Reader |
This example uses the FILENAME and FILE statements to write to an internal reader.
filename injcl '.misc.jcl' disp=shr;
filename outrdr sysout=a pgm=intrdr
recfm=fb lrecl=80;
data _null_;
infile injcl(myjcl);
file outrdr noprint notitles;
input;
put _infile_;
run;
| Writing to a Temporary Data Set |
The following examples use the FILENAME and FILE statements to write to a temporary data set.
filename tempfile '&mytemp' ; data out; file tempfile; put ...; run;
filename nextone '&mytemp' disp=new lrecl=80 blksize=320 space=(trk,(3)); data out; file nextone; put ...; run;
| Using the FILE Statement to Specify Data Set Attributes |
You can specify data set attributes in the FILE statement as well as in the FILENAME statement or FILENAME function. SAS supplies default values for any attributes that you do not specify. (For information about default values, see Overview of DCB Attributes and DCB Option Descriptions.)
filename x 'userid.newdata' disp=new
space=(trk,(5,1)) volume=xyz111;
data out;
file x lrecl=80 recfm=fb;
put ... ;
run;
| Using the Data Set Attributes of an Input File |
filename in 'userid.input'; filename out 'userid.output'; data; infile in; input; file out dcb=in; put _infile_; run;
| Using the FILE Statement to Specify Data Set Disposition |
In this example, the MOD option is used to append data to the end of an external file.
filename out 'user.output'; data _null_; /* New data is written to 'user.output' */ file out; put ... ; run; data _null_; /* data is appended to 'user.output' */ file out mod; put ... ; run;
filename out 'user.output' disp=mod; data _null_; /* data is appended to 'user.output' */ file out; put ... ; run; data _null_; /* data is written at the beginning of */ /* 'user.output' */ file out old; put ... ; run; data _null_; /* data is written at the beginning of */ /* 'user.output' */ file out; put ... ; run; data _null_; /* data is appended to 'user.output' */ file out mod; put ... ; run;
| Writing to Print Data Sets |
file saveit print;
file print;
The PRINT fileref in the FILE statement causes SAS to write the information either to the standard SAS procedure output file (PRINT=SASLIST), or to another output file if you have used a PROC PRINTTO statement to redirect your output. (See PRINTTO and Using the PRINTTO Procedure for information about PROC PRINTTO.) In either case, this file contains carriage-control characters by default. You can suppress the carriage-control characters by specifying the NOPRINT option in the FILE statement (see Writing to External Files).
file saveit recfm=vba;
| Designating a Print Data Set as a Nonprint Data Set |
file outdd noprint;
To write lines without carriage-control information to the SAS procedure output file, specify:
file print noprint;
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.