BookmarkSubscribeRSS Feed
robertrao
Quartz | Level 8

Hello Team,

 

I am trying to calculate percentages for the following data. The count of all records wil be my denominator.

I did a proc Summary and got the numerators very easily. It was difficult to put the denominator besides each category as shown below.

I created a variable cnt=1 for all records in the data step and used another proc summary step and merge it to the initial results. But this gave me denominator only once.(just the first record gets it)

Can someone help me with any easy methods available?

 

 

Have

ID   Category

101  High

102 Low

103 High

104 Low

105 Med

106 High

 

Want:

               Num         Den     Percent

High        3                6         3/6*100

Low         2                6         2/6*100

Med         1                6        1/6*100

2 REPLIES 2
Reeza
Super User

Proc freq. 

Cynthia_sas
SAS Super FREQ

And, in addition to PROC FREQ, you wouldn't want PROC TABULATE or PROC REPORT to feel left out! All 3 procedures will use the Grand Total of the count as the denominator when you ask for the percent or the PCTN statistic as shown below.

cynthia

 

_3_way_percent.png

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 2809 views
  • 0 likes
  • 3 in conversation