For question 1, I think this is the complete list. The DATA step retains (a) any variable mentioned in a RETAIN statement, (b) the first variable in a SUM statement, and (c) any variable that comes from a SAS data set (regardless of whether the SAS data set is being read with a SET, MERGE, or UPDATE statement). For question 2, yes the variable is retained. Your programming statements may overwrite that retained value, however. To illustrate, you might try creating some variations on these programs: data test1; put 'Before: ' x=; input dummy; retain x; x=_n_; put 'After: ' x=; datalines; 8 9 ; data _null_; put 'Before: ' x=; set test1; x=_n_ + 10; put 'After: ' x=; run;
... View more