Hello all:
I wonder if you can calculate percentage of nonmissing values using proc tabulate. What I need is sth. like
Mean
var Std
N
Percent of nonmissing values
Although the statistic can be calculated as simple as N/(N + NMISS), I cannot seem to find a way to do that directly.
Thanks,
Peter
Hi:
I'm confused. N+NMISS would equal the total number ...since, by definition, the N statistic is the count of non-MISSING values and NMISS is the count of MISSING values. But, for example if you have 4 observations:
name age gender height
alan 10 M 68.0
bob 11 .
carl . M 72.0
dave 12 72.4
you have 4 total observations. NAME has N=4 and NMISS=0; AGE has N=3 and NMISS=1; HEIGHT has N=3 and NMISS=1 and GENDER has N=2 and NMISS=2....so when you show Percent of non-missing, I get confused because the PCTN is automatically calculated with N (so it would be the percent of the nonmissing). But TABULATE will not "add" N+NMISS automatically. On the other hand, look at the difference the MISSING option has in PROC FREQ in the calculate of percentages.
cynthia
data testdata;
infile datalines dlm=',' dsd;
input name $ age gender $ height;
datalines;
alan, 10, M, 68.0
bob, 11, , .
carl, ., M, 72.0
dave, 12 , , 72.4
;
run;
ods listing;
proc print data=testdata;
run;
proc freq data=testdata;
title 'freq with missing option';
tables name gender age height / missing;
run;
proc freq data=testdata;
title 'freq without missing option';
tables name gender age height ;
run;
proc tabulate data=testdata missing;
title 'tabulate with n and nmiss';
var age height;
table age,(mean std n nmiss pctn);
table height,(mean std n nmiss pctn);
run;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.