Reputation: 157
I am confused with the output
statement . Here are two programs that both have output .
1) Program one . Produces 3 observations, just as I expect it, output
overwrites the default data step output
data test ;
infile datalines ;
input type $ @ ;
if type='a' then do;
input money ;
output ;
end;
datalines ;
a 100
b 200
a 500
a 400
x 500
v 500
;
run;
proc print;
run;
2) Program two . Produces 6 observations . Why doesn't output
overwrite this data step ?
data test ;
infile datalines ;
input type $ @ ;
if type='a' then input money ;
output ;
datalines ;
a 100
b 200
a 500
a 400
x 500
v 500
;
run;
proc print;
run;
Why output
in the first case does the job but in the second case it does not ?
Upvotes: 0
Views: 203
Reputation: 720
In the first program, output is part of a conditionally executed do group because it is between if type='a' then do;
and end;
. Therefore it only executes if type equals 'a'. In the second program, output is not part a do group at all, so it executes for all observations, thus all observations are output.
Upvotes: 5