The SAS Output Delivery System and reporting techniques

to generate missing value numbers in Proc freq or proc means

Reply
Contributor
Posts: 31

to generate missing value numbers in Proc freq or proc means

Dear all ,

My requirement is generate table for all posibles missing value numbers by using proc freq and proc means for below data and output is given below

i tried with below code but i am not geeting exact output and missing two values in output ""American" and "Indian" please see output below i want

proc format;

value trt

1 = "Active"

0 = "Placebo";

value race

1 = "White"

2 = "Black"

3 = "Cocasion"

4="American"

5="Indain" ;

run;

ods listing close;

ods output crosstabfreqs=data ;

proc freq data=demog ;

tables trt*race/missing sparse;

format race race. ;

run;

ods output close;

ods listing;

options missing='_' ;

proc means data=demog ;

class race/preloadfmt ;

format race race. ;

var trt ;

run;

data ;

data demog;

label subjid = "Subject Number"

trt = "Treatment"

race = "Race" ;

input subjid trt race ;

cards;

101 0 3

102 1 1

103 1 2

104 0 1

105 1 3

106 0 1

201 1 3

202 0 1

203 1 2

204 0 1

205 1 3

206 1 1 ;

Run;

output;

Race

Treatment  Placebo

Treatment Active

White

4

2

black

0

1

cocasian

1

3

America

0

0

Indian

0

0

Thanks & Regards,

Rajasekhar Reddy

Super User
Posts: 19,160

Re: to generate missing value numbers in Proc freq or proc means

Proc freq doesn't support PRELOADFMT in 9.3 at least. Proc tabulate will.

For Proc means use classdata option instead.

proc format;

value trt

1 = "Active"

0 = "Placebo";

value race

1 = "White"

2 = "Black"

3 = "Caucasian"

4="American"

5="Indain" ;

run;

data class_levels;

do race=1 to 5;

output;

end;

run;

proc means data=demog classdata=class_levels ;

class race;

format race race. ;

var trt ;

run;

proc tabulate data=demog;

class race trt/preloadfmt;

format race race. trt trt.;

table race, trt * N=''/printmiss;

run;

PROC Star
Posts: 1,146

Re: to generate missing value numbers in Proc freq or proc means

If your tables will contain large numbers of cells, PROC FREQ will break down first because of volume. PROC TABULATE will handle a higher number of result cells, and PROC MEANS is the best.

For large result tables, if I can functionally use PROC MEANS that's my preference.

Tom

Super User
Super User
Posts: 6,845

Re: to generate missing value numbers in Proc freq or proc means

To get MEANS/SUMMARY to generate all cells you need to include the COMPLETETYPES option.

proc summary data=demog(keep=race trt) nway  completetypes;

  class race trt/preloadfmt ;

  format race race. trt trt.;

  output out=summary ;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 542 views
  • 3 likes
  • 4 in conversation