Help using Base SAS procedures

percent of nonmissing in tabulate

Reply
Occasional Contributor
Posts: 12

percent of nonmissing in tabulate

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

SAS Super FREQ
Posts: 8,868

Re: percent of nonmissing in tabulate

Posted in reply to tradepeter

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;

Ask a Question
Discussion stats
  • 1 reply
  • 344 views
  • 0 likes
  • 2 in conversation