BookmarkSubscribeRSS Feed
rcleven2
Obsidian | Level 7

I am have been putting together a very large script of code that is being used to create a report that will be used very broadly. I have come to the very end and have ran in to a problem. The proc tabulate code that I have in place works, and creates the report the way I need it to look and functionally it does exactly what I need. The code calculates two statistics, Frequency count and a Percentage of the count within a by group. If a count is ever less than 5 the actual number is censored and only shows "<5". HOWEVER, the percentage is still calculated and any 5th grader could figure out the censored count just by computing its respective percentage.

 

I need to somehow suppress the percentage when the count is "<5". This can be in an ODs statement, format, tabulate or some step after tabulate, though that is not ideal. I can not figure out a way to get this to work. If i cant then i will have to go into excel and manually apply a format to SEVERAL sheets just to achieve my ultimate result. I am hopping someone here has the answer. 

 

Attache are a sample ds and the proc tabulate code to go with it. 

2 REPLIES 2
ballardw
Super User

@rcleven2 wrote:

I am have been putting together a very large script of code that is being used to create a report that will be used very broadly. I have come to the very end and have ran in to a problem. The proc tabulate code that I have in place works, and creates the report the way I need it to look and functionally it does exactly what I need. The code calculates two statistics, Frequency count and a Percentage of the count within a by group. If a count is ever less than 5 the actual number is censored and only shows "<5". HOWEVER, the percentage is still calculated and any 5th grader could figure out the censored count just by computing its respective percentage.

 

I need to somehow suppress the percentage when the count is "<5". This can be in an ODs statement, format, tabulate or some step after tabulate, though that is not ideal. I can not figure out a way to get this to work. If i cant then i will have to go into excel and manually apply a format to SEVERAL sheets just to achieve my ultimate result. I am hopping someone here has the answer. 

 

Attache are a sample ds and the proc tabulate code to go with it. 


Proc tabulate will not consider the values of any other cells for "conditional" appearance options. If you want to use Proc Tabulate then you may have to pre-summarize the data which would allow setting specific values for a format to work as with the count range.

 

OR use the Proc Tabulate OUT= feature to create a dataset and then modify that set before re-displaying with a different proc tabulate step. I will admit that the Tabulate output data set structure takes a bit to work with but it would have the values to modify easily and could be compared with the appropriate count. Have you actually looked at the TEST data set you created with your code?

ChrisNZ
Tourmaline | Level 20

As @ballardw said, you need to break the proc tabulate into two steps:

1. Pre-processing, where each cell value is calculated; you can alter the results as see fit.

2. Proc tabulate displays the results, no calculations are performed as each cell displays one (pre-calculated) figure.

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
  • 2 replies
  • 550 views
  • 0 likes
  • 3 in conversation