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
@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
Thank you Reeza
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!
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.