06-28-2016 09:33 AM
I am unable to understand how this program is giving output for 8 observation and repeating 1, 2 and 5???
input Var1 $ Var2 $;
data one two;
if Var1='A' then output WORK.ONEs;
06-28-2016 09:59 AM - edited 06-28-2016 10:00 AM
Data step processes the input dataset row by row.
If there is no explicit output instruction in the code,
the currently processed row (*) is output when the interpreter
hits the run instruction. If there remains rows to process, there
is an implicit loop and the instructions in the data step are
executed again for the next row of the input dataset.
(*) More precisely the program data vector (PDV) wich is SAS terminology to
indicate the data being processed (row extracted from the input dataset + newly
On the other hand, when the code in the data step contains some
output instructions, those determine when to output new lines in the
created dataset and the run instruction does not implicitely output
So in your code, for each input row where Var1='A', the instruction
creates a new row in table ONE.
The following output instruction creates a new row in both output datasets.
With 3 rows having Var1='A' and two rows where Var1 <> 'A',
the ONE dataset will have : 3x2+2=8 rows.