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 🙂

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 817 views
  • 0 likes
  • 2 in conversation