I have been struggling to force cells with a '0' to appear in my proc report. For instance:
term1 | term2 | |
---|---|---|
apples | 0 | 0 |
oranges | 2 | 10 |
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!
Use the PreloadFMT with proc report:
http://support.sas.com/resources/papers/proceedings11/239-2011.pdf
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;
thanks guys! COMPLETEROWS looks like the way to go
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.