One quick question: why does sas solve the following code
data prova_2;
input id_2 $ age_2;
datalines;
zz 22
zz 22
zz 22
zz 23
xx 22
xx 24
aa 25
;
run;
data prova_2;
set prova_2;
if id_2="zz" then do; if age_2=23; end;
run;
by outputting the following table?
I would instead expect it to output just one single line, ie, line 1, the one with id_2="zz" and age_2=23. Any idea?
Thanks in advance!
You are running the subsetting IF only on SOME of the observations.
So all observations where ID_2 is not zz will also continue to the end of the data step and be written out.
So you are doing the equivalent of
if (id_2='zz') and (age_2 ne 23) then DELETE;