I am running PROC REPORT to compute sample counts and percent of total on a cross-tabulation of variables. In parts of the cross-tab I have no representatives for the variables involved. Initially this just printed as a missing value, but I utilized OPTIONS MISSING=0 to fill with 0's. However, since one of the associated columns calculates a percentage, I would rather that it say 0%. I'm not sure how to make this work.
Code:
proc report data=mfb_ly nowd split="*"
style(report)=[frame=hsides rules=none]
style(header)=[background=white color=&rgreen. borderbottomcolor=black]
style(lines)=[background=white];
where(not missing(mech));
options missing=0;
column mech type,(nationalweight nationalweight=pct) ('Overall' nationalweight=tot nationalweight=totpct ) ;
define mech / group 'Activity' center order=freq descending style(column)=[cellwidth=2.5in just=l] style(header)=[just=l];
define type / across '';
define nationalweight / analysis SUM 'n' format=comma8.0 &cl.;
define pct / analysis PCTSUM format=percent8.1 '%' style(column)=[cellwidth=0.75in just=c];
define tot / analysis sum 'n' format=comma8.0 &cl.;
define totpct / analysis pctsum '%' format=percent8.1 order=freq style(column)=[cellwidth=0.75in just=c];
rbreak after /summarize style(summary)={font_weight=bold};
compute mech;
if _break_ = '_RBREAK_' then mech = 'Total';
endcomp;
run;
Output:
Maybe create a new format?
proc format;
value pct low-high=[percent8.1] .='0%';
Maybe create a new format?
proc format;
value pct low-high=[percent8.1] .='0%';
> Would have loved to see a solution that was specific to the PROC
You might be able to compute something. I like formats 🙂
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.