BookmarkSubscribeRSS Feed
-a_a-rlis
Calcite | Level 5

I have a dataset like below:

 

Finality        Balance

a                    10

b                    15

c                     8

d                    30

 

First, I would like to sum the finalities 'a' and 'd', resulting in 40. Then, this result must be divided by the sum of all rows. Is there a way to do so, since I have to do the same thing for b and c, separately (dividing 'b' by the sum of all rows and so on)?

The final table I need is something like:

Finality        Result

e (a+d)         0.6349

b                  0.2381

c                  0.1270

 

I don't know if I made myself clear. Sorry if don't.

4 REPLIES 4
ballardw
Super User

If you only have four rows then do this by hand.

 

If you have lots more rows then more complete example data and the RULES, not the rows, but how do we know that A and D rows are the ones to add, as well as the B and C? There is not immediately obvious surface logic that says these specific pairs should be added.

novinosrin
Tourmaline | Level 20

"If you only have four rows then do this by hand."---

 

Sir @ballardw  Not really participating in this thread or much today as I am not feeling well, but that comment made me laugh. I didn't know you had a sense of humor. Nice to notice that. 🙂

ballardw
Super User

@novinosrin 

Hope feel better soon.

 

Some have considered my humor odd at times.

In this case I am actually moderately serious with the number of missing elements of the problem description.

Reeza
Super User

Use a custom format, along with PROC FREQ.

 

proc format;
value final_fmt
'a', 'd' = ' e (a+d)'
other = [$8.];
run;

proc freq data=have;
table finality / out=want outpct;
format finality final_fmt.;
run;

@-a_a-rlis wrote:

I have a dataset like below:

 

Finality        Balance

a                    10

b                    15

c                     8

d                    30

 

First, I would like to sum the finalities 'a' and 'd', resulting in 40. Then, this result must be divided by the sum of all rows. Is there a way to do so, since I have to do the same thing for b and c, separately (dividing 'b' by the sum of all rows and so on)?

The final table I need is something like:

Finality        Result

e (a+d)         0.6349

b                  0.2381

c                  0.1270

 

I don't know if I made myself clear. Sorry if don't.


 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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