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?
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:
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
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.
@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.
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:
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
This block is likely what I need.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.