Writing Observations Explicitly

To override the default way in which the DATA step writes observations to output, you can use an OUTPUT statement in the DATA step. Placing an explicit OUTPUT statement in a DATA step overrides the automatic output, so that observations are added to a data set only when the explicit OUTPUT statement is executed.
Syntax, OUTPUT statement:
OUTPUT <SAS-data-set(s)>;
SAS-data-set(s) names the data set or data sets to which the observation is written. All data set names that are specified in the OUTPUT statement must also appear in the DATA statement.
Using an OUTPUT statement without a following data set name causes the current observation to be written to all data sets that are specified in the DATA statement.
With an OUTPUT statement, your program now writes a single observation to output—observation 5.
data work.getobs5; 
   obsnum=5; 
   set sasuser.usa(keep=manager wagerate) point=obsnum;
   output; 
   stop; 
run; 
proc print data=work.getobs5 noobs; 
run;
Figure 12.8 Single Observation
Single Observation
Suppose your DATA statement contains two data set names, and you include an OUTPUT statement that references only one of the data sets. The DATA step creates both data sets, but only the data set that is specified in the OUTPUT statement contains output. For example, the program below creates two temporary data sets, Empty and Full. The result of this DATA step is that the data set Empty is created but contains no observations, and the data set Full contains all of the observations from Sasuser.Usa.
data empty full; 
   set sasuser.usa; 
   output full; 
run;
Last updated: January 10, 2018
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.245.233