BookmarkSubscribeRSS Feed
jpeevy
Calcite | Level 5

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!

3 REPLIES 3
Cynthia_sas
SAS Super FREQ

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
jpeevy
Calcite | Level 5

thanks guys! COMPLETEROWS looks like the way to go

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 935 views
  • 1 like
  • 3 in conversation