标题: how to check blank value in a sas dataset? [打印本页] 作者: shiyiming 时间: 2009-8-13 13:59 标题: how to check blank value in a sas dataset? hello everyone,
my question likes this,
i want to check if there is missing value in my dataset, always i will code below,
data checktmp;
set mydataset;
if var_a='' or var_b=. or var_c=. then output;
run;
while if there are so many variables and i am so tired to type every columns there, so does there have any option will help me? thanks.作者: shiyiming 时间: 2009-8-13 15:09 标题: Re: how to check blank value in a sas dataset? %macro outmissing(data = ,var= ,out = );
data &out;
set &data.(keep=&var.);
array arraynum{*} _numeric_;
do i = 1 to dim(arraynum);
if arraynum{i} = . then output;
end;
array arraychar{*} _character_;
do i = 1 to dim(arraychar);
if arraychar{i} = ' ' then output;
end;
run;
proc print;
run;
%mend outmissing;
data a;
do i = 1 to 3;
x = i**2;
y = substr('abc', i, 1);
if i = 1 then x = .;
if i = 2 then y = ' ';
output;
end;
run;
%outmissing(data = a, var=x, out = b);作者: shiyiming 时间: 2009-8-13 15:23 标题: Re: how to check blank value in a sas dataset? data aa;
input f b c d e;
cards;
1 2 . . 3
. . . . .
2 3 4 5 6
;
run;
data bb;
set aa;
array missing f b c d e;
do over missing;
if missing=. then output bb ;
end;
run;
proc sql;
create table cc as
select distinct *
from bb;
quit;作者: shiyiming 时间: 2009-8-13 17:35 标题: Re: how to check blank value in a sas dataset? many thanks gzgoon and smand008 for so quick reply. and your code really help me.