SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Creating Multiple Observations from a Single Record
Reading the Same Number of Repeating Fields


Explicitly Writing an Observation

Each time the loop executes, you need to write the values for ID, Quarter, and Sales as an observation to the data set. This is easily accomplished by using the OUTPUT statement.


General form, OUTPUT statement:
OUTPUT <SAS-data-set>;

where SAS-data-set names the data set to which the observation is written. All data set names 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 named in the DATA statement.


     data perm.sales97;
        infile data97;
        input ID $4. @;
        do Quarter=1 to 4;
           input Sales : comma. @; 
           output; 
        end;
     run;               
By default, every DATA step contains an implicit OUTPUT statement at the end of the step. Placing an explicit OUTPUT statement in a DATA step overrides the automatic output, and the SAS System adds an observation to a data set only when the explicit OUTPUT statement is executed.



back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement