tags:

views:

688

answers:

1

Using PROC REPORT in SAS, if a certain ACROSS variable has 5 different value possibilities (for example, 1 2 3 4 5), but in my data set there are no observations where that variable is equal to, say, 5, how can I get the report to show the column for 5 and display 0 for the # of observations having that value?

Currently my PROC REPORT output is just not displaying those value columns that have no observations.

+2  A: 

When push comes to shove, you can do some hacks like this. Notice that there are no missing on SEX variable of the SASHELP.CLASS:

proc format;
  value $sex 'F' = 'female' 'M' = 'male' 'X' = 'other';
run;

options missing=0;
proc report data=sashelp.class nowd ;
  column age sex;
  define age/ group;
  define sex/ across format=$sex. preloadfmt;
run;
options missing=.;
/*
                  Sex
    Age  female  male    other
     11       1       1       0
     12       2       3       0
     13       2       1       0
     14       2       2       0
     15       2       2       0
     16       0       1       0
*/
Chang Chung
I'm confused as to what's allowing that 'Other' column to show. Is it the preloaded format? Also, will this work when, of the 5 values in my example, there are 2 or 3 that have no observations?
chucknelson
@chucknelson yes. yes.
Chang Chung
Thanks again for your help Chang, worked like a charm!
chucknelson