A very simple example of unintended consequenses of inserting a retain statement.
Yes this behaves as documented, but if one is not aware of everything happening in a datastep, stuff happens.
data one;
do x = 1 to 10 ;
output;
end;
run;
data two;
retain y x; * run with and without;
set one(rename = (x = y));
if y = 3 then x = y;
run;
proc print;
run;
I think a middle ground is best, I never say "Never" , just be carefull.
And thanks for the discussion to make us all think.
And now I see why that old macro started acting up: I tried out your technique of putting in a retain to order the variables, there was a rename in the macro. So it retained the value when it got to a missing value. since the datastep has several macro calls and 350 variables and 10**9 records it took a while to find the cause.
So yea, even an old timer like me can make a mistake.
Message was edited by: Flip
... View more