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