Forcing cells with 0 counts in Proc Report

Reply
Occasional Contributor
Posts: 7

Forcing cells with 0 counts in Proc Report

I have been struggling to force cells with a '0' to appear in my proc report. For instance:

term1term2

apples

00
oranges210

However, since there are 0 entries on the entire row for apples, it will not appear on my report. I have read articles on how to do this for proc trabulate with the 'classdata' option. However, I can't figure it out when using the proc report feature. If anyone can offer advice, or point me in the right direction, it would be appreciated.

thanks!

Super User
Posts: 19,878

Re: Forcing cells with 0 counts in Proc Report

SAS Super FREQ
Posts: 8,869

Re: Forcing cells with 0 counts in Proc Report

Hi:

  In PROC REPORT, you can use COMPLETEROWS or COMPLETECOLS to "complete" columns or rows for which there is no data. For example, there are no age 16 females in SASHELP.CLASS. Consider the difference in the following code in these 3 examples. Output is shown in the screen shot. You can experiment if you are using an ACROSS variable with COMPLETECOLS and PRELOADFMT. Also, you should be sure to set the SAS system option:

options missing=0; to be sure that the usual . for missing appears as 0.

Cynthia

ods _all_ close;

proc format;

  value $sexf 'F' = 'Female'

             'M' = 'Male'

    'U' = 'Unknown';

run;

   

ods html file='c:\temp\show_0_row.html';

proc report data=sashelp.class nowd;

  where age ge 14;

  title '1) without completerows';

  column age sex n;

  define age / group;

  define sex / group;

run;

proc report data=sashelp.class nowd completerows;

  where age ge 14;

  title '2) with completerows';

  column age sex n;

  define age / group;

  define sex / group;

run;

proc report data=sashelp.class nowd completerows;

  where age ge 14;

  title '3) with completerows and preloadfmt';

  column age sex n;

  define age / group;

  define sex / group f=$sexf. preloadfmt;

run;

ods html close;


proc_report_row_with_0.png
Occasional Contributor
Posts: 7

Re: Forcing cells with 0 counts in Proc Report

thanks guys! COMPLETEROWS looks like the way to go

Ask a Question
Discussion stats
  • 3 replies
  • 204 views
  • 1 like
  • 3 in conversation