BookmarkSubscribeRSS Feed
DiG
Fluorite | Level 6 DiG
Fluorite | Level 6

Hello dear experts,

 

I am facing a challenge today: need to find a sum of payments for groups of subjets ('Name' in the table below) that fall within assets ranges: 

name assets payment
A                100,400 456
B                300,500 1344
C                100,800 357
D            1,800,000 7348
E            300,003 467
F                340,000 966
G          15,000,900 34533

 

H        785,004,000 7238

 

The ranges start from 100,000 and increment every 100,000 until 10,000,000. Whatever is greater than 10,000,000 is grouped together. So, there are 100 assets ranges:

100,001-200,000

200,001-300,000

...

1,900,001-2,000,000

2,000,001-2,100,000

...

10,000,000 and over

 

For example, payment for A and C will be summarized together. Same goes with B, E, and F. Also G and H.

 

I know it should be a loop with an incremental value to calculate sum of payments for each asset range but I can't figure it out. Need your help please!

 

Thanks

2 REPLIES 2
Reeza
Super User

@DiG wrote:

 

I know it should be a loop with an incremental value to calculate sum of payments for each range but I can't figure it out. Need your help please!

 

 

I'm not sure what that means, but a SAS way of doing this easily is: 

 

1. Create a format that contains your intervals. 

2. Apply the format using a PUT statement to identify your groups.

3. Then sum using PROC MEANS. 

 

Example for #1

http://documentation.sas.com/?docsetId=proc&docsetVersion=9.4&docsetTarget=n1e19y6lrektafn1kj6nbvhus...

 

 

 

 

 

DiG
Fluorite | Level 6 DiG
Fluorite | Level 6

Thank you Reeza

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1371 views
  • 2 likes
  • 2 in conversation