BookmarkSubscribeRSS Feed
rahulramesh3321
Calcite | Level 5

Hi Everyone,

 

I am stuck in one problem where I am not able to program it. Sample data is given below : 

 

 

IDA1xB1y Output
AA875000001750000000 87500000
AA0628420515.9 31421025.8
AA0603509371 30175468.55
BB                          40,000               800,000             40,000
BB0720,000 36000
CC                       440,250           8,805,000           440,250
CC0           7,885,000           394,250
CC0           6,458,720           322,936
CC0           2,571,356     128,567.80

 

Output Calculation : 

For AA

OBS         output

1               87500000

2               (87500000/1750000000)*628420515.9 = 31421025.8

3               (87500000 +31421025.8 /1750000000 + 628420515.9) * 603509371 = 30175468.55

 

For CC

OBS        Output

1             440,250

2             (440,250 / 8,805,000)*7,885,000 = 394,250

3              (440,250 + 394,250/ 8,805,000 +7,885,000)*6,458,720 = 322,936

4              (440,250 + 394,250+322,936/ 8,805,000 +7,885,000+6,458,720) * 2,571,356 = 128,567.80

 

I have tried with using lag and cumulative but not able to go beyond obs =2 and also got issue in implementing in the subgroup.

I had a thought of using array and loop but it was making program quite complicated and also not getting the desired output.

 

Please help.

2 REPLIES 2
lalaktgrau
Fluorite | Level 6

hey, can you create a dataset using DATALINES, so I can play with it in SAS?

rahulramesh3321
Calcite | Level 5

Sure,

 

data test;
infile datalines delimiter=',';
input ID$ A1x B1y;
datalines;
AA,87500000,1750000000
AA,0,628420515.9
AA,0,603509371
BB,40000,800000
BB,0,720000
CC,440250,8805000
CC,0,7885000
CC,0,6458720
CC,0,2571356
;

run;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 569 views
  • 0 likes
  • 2 in conversation