DATA Step, Macro, Functions and more

Calculate Percent

Accepted Solution Solved
Reply
Contributor
Posts: 50
Accepted Solution

Calculate Percent

Hi All,

 

I have a dataset as below and wondering if there is a way I can use Proc Sql to create the new column Percent. I am trying code below which does not work and it gives me 100% for all values -

 

proc sql;
create table test as select a.*,
( Value/ sum(Value) ) as Percent
from test a
group by month,Range;
quit;

 

 

month Id Value Range Percent
Apr 4 3026 (0,20] 39.0%
Apr 4 1627 (20,60] 21.0%
Apr 4 700 (60,70] 9.0%
Apr 4 2406 (70,80] 31.0%
Aug 8 3275 (0,20] 41.2%
Aug 8 1579 (20,60] 19.9%
Aug 8 669 (60,70] 8.4%
Aug 8 2419 (70,80] 30.5%

 

 

Kind regards

SK


Accepted Solutions
Solution
‎09-04-2016 01:43 PM
Respected Advisor
Posts: 3,124

Re: Calculate Percent


All Replies
Solution
‎09-04-2016 01:43 PM
Respected Advisor
Posts: 3,124

Re: Calculate Percent

Group by month;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 1 reply
  • 211 views
  • 1 like
  • 2 in conversation