I always thought that the variables are set to missing for every iteration of the data step . However, in the following code, it looks like the value that the variable gets at the very beginning retains. I can't understand why this happens ?
data one;
input x $ y;
datalines;
a 10
a 13
a 14
b 9
;
run;
data two;
input z;
datalines;
45
;
run;
data test;
if _n_ = 1 then set two; /* when _n_=2 the PDV assigns missing values, right ? */
set one;
run;
proc print;
run;
The outcome is
z x y
45 a 10
45 a 13
45 a 14
45 b 9
I was expecting to get this
z x y
45 a 10
. a 13
. a 14
. b 9
SAS does not reset the values in PDV for - SET, MERGE, MODIFY, or UPDATE statements. Since you are using SET statement so SAS is not resetting it.
if _n_ = 1 then set two;
http://support.sas.com/documentation/cdl/en/lrcon/65287/HTML/default/viewer.htm#p08a4x7h9mkwqvn16jg3xqwfxful.htm
Read - The Execution Phase - Pointer 5
http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001290590.htm
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000961108.htm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With