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

I received a request to a function that feeds in 1 to 4 columns variables from a table and 1 to 4 row variables and creates a tabulate statement from them.  This part is easy.  Any advice on how to dynamically handle percent of for a measure being passed?

 

Is there an article that gives an example?

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

Hi:

  TABULATE has keyword statistics ROWPCTSUM, COLPCTSUM and PCTSUM, PAGEPCTSUM, etc, that you use to control the denominator of a percent. If you are prompting them for information, you'd have to ask them what percent they want to see and start with the simple 3:

 

  Even if you are not going to show the Grand Total or the Row Total or the Column Total, I like to make sure that people understand what the keyword statistics are going to produce before I let them pick.

 

  If they want anything other than the N, that moves you to needing a VAR statement and a SUM statistic. The percent statistic they get will or should be based on where they expect the 100% to be. This is what I give them to start, something like:

_3_diff_percents.png

 

That way, they can imagine their own data and where you see the 100 in the percent column indicates which SUM was used as the denominator for the percent calculation.

 

Not a full answer, but a place to start.

 

Cynthia

View solution in original post

5 REPLIES 5
Reeza
Super User
Not clear what you mean by a percent or measure being passed and what you want to do with it.
DavidPhillips2
Rhodochrosite | Level 12

If a user wants to see a column breakout by pct of total rather than a numeric count of a column.  Or a user wants to see both.

ballardw
Super User

@DavidPhillips2 wrote:

If a user wants to see a column breakout by pct of total rather than a numeric count of a column.  Or a user wants to see both.


Is "total" a total count or a sum of some VAR variable?

COLPCTN or COLPCTSUM look like the desired statistics without a more concrete example.

 

 

Cynthia_sas
SAS Super FREQ

Hi:

  TABULATE has keyword statistics ROWPCTSUM, COLPCTSUM and PCTSUM, PAGEPCTSUM, etc, that you use to control the denominator of a percent. If you are prompting them for information, you'd have to ask them what percent they want to see and start with the simple 3:

 

  Even if you are not going to show the Grand Total or the Row Total or the Column Total, I like to make sure that people understand what the keyword statistics are going to produce before I let them pick.

 

  If they want anything other than the N, that moves you to needing a VAR statement and a SUM statistic. The percent statistic they get will or should be based on where they expect the 100% to be. This is what I give them to start, something like:

_3_diff_percents.png

 

That way, they can imagine their own data and where you see the 100 in the percent column indicates which SUM was used as the denominator for the percent calculation.

 

Not a full answer, but a place to start.

 

Cynthia

DavidPhillips2
Rhodochrosite | Level 12

This block is likely what I need.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 874 views
  • 2 likes
  • 4 in conversation