boe 发表于 2013-6-10 13:30 
前面那个靠谱些,后面那个_col6 还有缺失值,具体原因未知。
还请大牛们给指点一下子。。。。。。
十分感谢您的细心指点。
附件是变量的解释。我想对_col4,_col5,_col25-_col30重新写判断它们有效性的条件。不仅每列的值在选项范围内,并且要符合答题条件。如果看了附件有什么疑惑请及时和我联系。下面是我写的代码,但感觉不对,好像输出的结果有点少,求改进。
%macro valid(r);
%do i=1 %to &r;
data b&i;set a&i;
if not((((_col4=2) and missing(_col5)) or ((_col4=1) and _col5 in(1,2,3))) and
((_col25=1 and _col26 in(1,2,3,4) and _col27 in(1,2) and _col28 in(1,2,3,4,5,6)and _col29 in(1,2,3) and _col30 in(1,2,3)) or
(_col25=2 and missing(_col26) and missing(_col27) and missing(_col28) and missing(_col29) and missing(_col30))) and
((_col27=1 and _col28 in(1,2,3,4,5,6) and _col29 in(1,2,3) and _col30 in(1,2,3))or
(_col27=2 and missing(_col28) and missing(_col29) and missing(_col30)))) then output;
run;
%end;
%mend morevalid;
%morevalid(22);
source.doc
(31.5 KB)