在LZ 的例子中, 感觉是 if 在起作用。
在run;语句前使用if 或 where 同样有output的作用。不用output也可以。就这个例子来讲,用不用retain 结果是相同的。
比如
data d; /* NOTE: The data set WORK.D has 0 observations and 3 variables */
set a;
retain z;
z = y;
if x=2;
run;
data e; /* NOTE: The data set WORK.E has 3 observations and 3 variables */
set a;
retain z;
z = y;
if x^=2;
run;