boe 发表于 2013-6-6 23:41 
这是转置过的数据?
在转置之前,用数组可能也能操作。。。
下面的代码是我想实现的,求有没有简单的代码来实现那?
%macro valid(r);
%do i=1 %to &r;
data b&i;set a&i;
if (max(_col2, _col4, _col6, _col7, of _col18-_col25)in (1,2) and min(_col2, _col4, _col6, _col7, of _col18-_col25) in (1,2)) and
(_col5 in(1,2,3)) and
(max(_col3, _col8)in (1,2,3,4) and min(_col3, _col8)in (1,2,3,4)) and
(max(of _col10-_col17)in (1,2,3,4,5) and min(of _col10-_col17) in (1,2,3,4,5)) and
(_col9 in(1,2,3,4,5,6,7,8,9,10,11,12)) and
(max(of A1-A24)in (1,2,3,4,5) and min(of A1-A24) in (1,2,3,4,5)) and
(max(of B1-B30)in (1,2,3,4,5) and min(of B1-B30) in (1,2,3,4,5)) and
(max(of C1-C68)in (1,2,3,4,5) and min(of C1-C68) in (1,2,3,4,5)) then output b&i;
run;
%end;
%mend valid;
%valid(20);
但是这个代码的最后结果会包含缺失值,我想把缺失值也给删除,怎么实现那?下面这个代码对吗?
%macro nonmiss(r);
%do i=1 %to &r;
data b&i;set b&i;
%do j=0 %to 25;if missing(_col&j) then delete;%end;
%do j=1 %to 24;if missing(A&j) then delete;%end;
%do j=1 %to 30;if missing(B&j) then delete;%end;
%do j=1 %to 68;if missing(C&j) then delete;%end;
run;
%mend nonmiss;
%nonmiss(20);
如果我想筛选出有效的数据(条件见上面的代码)并删除有缺失值得行,有没有代码可以同时实现?不用编2个宏了。
十分感谢!