|
Lance,
Yet another array way:
Sample Data:
%let N = 2010;
data have;
array s[*] $1 SNP1 - SNP50;
do id = 1 to &N;
do i = 1 to 50;
if ranuni(123) > .3 then s[i] = '1';
else s[i] = ' ';
end;
output;
end;
drop i;
run;
Array solution:
data need;
array k[50] _temporary_ ;
do until(eof);
set have end = eof;
array s[*] $1 SNP1 - SNP50;
do _n_ = 1 to dim(k);
if s[_n_] ne ' ' then k[_n_] ++ 1;
end;
end;
do i = 1 to dim(k);
k[i] = (&N - k[i]) / &N * 100;
Name = vname(s[i]);
Missing = k[i];
output;
end;
keep Name Missing;
run;
proc print data = need;
run;
Kind regards,
Muthia Kachirayan
On Wed, Feb 3, 2010 at 1:10 AM, Lance Smith <medicaltrial@gmail.com> wrote:
> Hi
>
> I have a dataset with 50 character variables (SNP1 - SNP50), each of
> which have a certain amount of missing data. I want to create a table
> that will give me the percentage of missing data per variable. Maybe
> something like this:
>
> VARIABLE N %MISSING
> SNP1 2010 2.6%
> .
> .
> .
> .
> .
> SNP50 2010 5%
>
> How do I do this in SAS?
> Thank you for your help.
>
|