data n2 (drop=_:);
array _v[5] x1-x5;
set w;by id;
_diff=constant("big");
do _i=1 to 5;
if not missing(_v(_i)) then do;
_ndiff=abs(_v[_i]-16);
if _ndiff=>_diff then continue;
_diff=_ndiff;
x6=_v[_i];
end;
end;
run;作者: shiyiming 时间: 2012-9-22 23:59 标题: Re: 变量值的选择 [quote="sun59338":c43tps2u]加上一个判断- if not missing(_v(_i)) then do;.....;end;
data n2 (drop=_:);
array _v[5] x1-x5;
set w;by id;
_diff=constant("big");
do _i=1 to 5;
if not missing(_v(_i)) then do;
_ndiff=abs(_v[_i]-16);
if _ndiff=>_diff then continue;
_diff=_ndiff;
x6=_v[_i];
end;
end;
run;[/quote:c43tps2u]
<!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> 谢谢,受用了~~~