BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
tburus
Obsidian | Level 7

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:

plot.png

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Maybe create a new format?

proc format;
  value pct low-high=[percent8.1]  .='0%'; 

 

View solution in original post

3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

Maybe create a new format?

proc format;
  value pct low-high=[percent8.1]  .='0%'; 

 

tburus
Obsidian | Level 7
That did the trick. Thanks. Would have loved to see a solution that was specific to the PROC and didn't require creating a new coded item, but I couldn't find one (if one even exists).
ChrisNZ
Tourmaline | Level 20

> Would have loved to see a solution that was specific to the PROC 

You might be able to compute something.  I like formats 🙂

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1162 views
  • 0 likes
  • 2 in conversation