EA 发帖数: 3965 | 1 我想删除那些都是missing value的变量,有什么办法么?
比如有一组数据,有很多变量,其中一些char type变量都是空的,我想找到这些变量
然后删除.用array怎么做? |
EA 发帖数: 3965 | 2 I google some code and made some changes, but it didn't work, can anyone
help me out?
data _null_;
array test(*) _character_;
array allmiss (*) $ _temporary_ ('true');
length list $ 50;
set missing end=end;
do i=1 to dim(test);
if test(i) ne '' then allmiss(i)='false';
end;
if end=1 then
do i= 1 to dim(test);
if allmiss(i) ='true' then list=trim(list)||' '||trim(vname(test(i)));
end;
call symput('mlist',list);
run;
data notmiss;
set missing;
drop &mlist;
run; |
h***x 发帖数: 586 | 3 The following codes should works,
say you have dataset named 'aaa' and you want to get rid of the character
variables whose values are all missing,
ods output NLevels=_out_;
proc freq data=aaa nlevels; run;
ods output close;
data _out_;
set _out_;
if NLevels=1 and NMissLevels=1;
run;
proc sql ;
select tablevar into: cvar
separated by ' '
from _out_;
quit;
data aaa;
set aaa(drop=&cvar);
run;
【在 EA 的大作中提到】 : 我想删除那些都是missing value的变量,有什么办法么? : 比如有一组数据,有很多变量,其中一些char type变量都是空的,我想找到这些变量 : 然后删除.用array怎么做?
|
l***a 发帖数: 12410 | 4 a simple proc freq and merge will do it
【在 EA 的大作中提到】 : 我想删除那些都是missing value的变量,有什么办法么? : 比如有一组数据,有很多变量,其中一些char type变量都是空的,我想找到这些变量 : 然后删除.用array怎么做?
|