DATA Step, Macro, Functions and more

Code involving an incremental value (100 times)

Reply
Occasional Contributor DiG
Occasional Contributor
Posts: 19

Code involving an incremental value (100 times)

[ Edited ]

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

Super User
Posts: 19,861

Re: Code involving an incremental value (100 times)


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...

 

 

 

 

 

Occasional Contributor DiG
Occasional Contributor
Posts: 19

Re: Code involving an incremental value (100 times)

Thank you Reeza

Ask a Question
Discussion stats
  • 2 replies
  • 126 views
  • 2 likes
  • 2 in conversation