我想转无效的值,以一个单一的值,并将它们只打印具有这些值的OB的ID的=>我有多个错误是第二部分(循环),是有可能以某种方式解决这个代码,或者是它根本不可能做到这一点这样?
data comb8;set comb;
if q2 not in (1,2,3,4,5)then q2=666;
if q3 not in (1,2,3,4,5)then q3=666;
if q10 not in (1,2,3,4,5)then q10=666;
if gender not in(0,1)then gender=666;
if married not in(0,1)then married=666;
run;
data comb10; set comb8;
do i=1 to n;
if i NE 666 then drop(?????????);
end;
keep id;
run;
希望我理解这个正确的-最终的结果你追求的是只保留一个包含任何你正在检查的标准值无效任何观察obervation多少? 如果是的话,试试这个:
data comb8(keep=id where=(not missing(obid)));
set comb;
if q2 not in (1,2,3,4,5) then obid=_n_;
if q3 not in (1,2,3,4,5) then obid=_n_;
if q10 not in (1,2,3,4,5) then obid=_n_;
if gender not in(0,1) then obid=_n_;
if married not in(0,1) then obid=_n_;
run;
_n_
是标识已在从该组语句被加载的观测数的自动变量。 当一个问题被发现,你可以设置OBID这个值,然后使用(where=(not missing(obid)))
只记住这有无效值的观察
万一它是帮助别人以后...
data comb8;set comb;
if q2 not in (1,2,3,4,5)then q2=666;
if q3 not in (1,2,3,4,5)then q3=666;
if q10 not in (1,2,3,4,5)then q10=666;
if gender not in(0,1)then gender=666;
if married not in(0,1)then married=666;
run;
data comb10(keep=obid where=(not missing(obid)));
set comb8;
Array Q q1-q10 gender married . ;
do i=1 to dim(Q) ;
if Q[i] EQ 666 then obid=_n_;
end;
run;