BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
BaalaRaaji
Quartz | Level 8

Hi Team,

 

I have a data since 2007 and trying to calculate the cumulative /running totals by Clnt and Month.

Not sure the last record is not populating correctly..

 

Below is the data i got from the below code...

 

CLNT_ITXCT_MTHNP_AmountIP_AmountWB_AmountWO_AmountNet_PositionCum_Netposition
9831Jan200900-500000-50000-50000
8730Sep200833547.970033547.9700
93031May2017050000005000050000
93030Jun20170000050000
26931Aug2011370000000370000370000
26931Oct2011017000000170000540000
26930Sep20120408276.7500408276.75948276.75
26931May20130306000003060001254276.75
26930Jun2013000857545.91-857545.91396730.84
26930Jun201400-101616.63295114.21-396730.84-5.82077E-11

 

I have calculated the Net position using the below logic.

 

calculated NP + calculated IP + calculated WB- calculated WO) as Net_Position

 

Not sure what is missing from the below code to calculating the running totals on the Net_Position.

 

proc sort data= Farlo_IAP_Clients_M nodupkey ; by TIAM_CLNT_I TXCT_MTH ;run;

data Farlo_IAP_Clients_C;
retain Cum_Netposition Cum_IAP_Amount Cum_IAP_Increase Cum_TotWO_Amount Cum_WriteOFF_Amount Cum_IFRWriteOFF_Amount
Cum_WriteBack_Amount Cum_DWriteOff_Amount ;
set Farlo_IAP_Clients_M;
by TIAM_CLNT_I TXCT_MTH;
if first.TIAM_CLNT_I and first.TXCT_MTH then
cum_Netposition=0; else cum_Netposition = cum_Netposition+(Net_position);

if first.TIAM_CLNT_I and first.TXCT_MTH then
cum_IAP_Amount=0;
cum_IAP_Amount+IAP_Amount;

if first.TIAM_CLNT_I and first.TXCT_MTH then
cum_IAP_Increase=0;
cum_IAP_Increase+IAP_Increase;

if first.TIAM_CLNT_I and first.TXCT_MTH then
Cum_TotWO_Amount=0;
Cum_TotWO_Amount+Total_WritOffAmount ;
if first.TIAM_CLNT_I and first.TXCT_MTH then
Cum_WriteOFF_Amount=0;
Cum_WriteOFF_Amount+WriteOFF_Amount ;

if first.TIAM_CLNT_I and first.TXCT_MTH then
Cum_IFRWriteOFF_Amount=0;
Cum_IFRWriteOFF_Amount+IFRWriteOFF_Amount ;

if first.TIAM_CLNT_I and first.TXCT_MTH then
Cum_WriteBack_Amount=0;
Cum_WriteBack_Amount+WriteBack_Amount ;
if first.TIAM_CLNT_I and first.TXCT_MTH then
Cum_DWriteOff_Amount=0;
Cum_DWriteOff_Amount+DWriteOff_Amount;

run;

proc sort data= Farlo_IAP_Clients_C; by TIAM_CLNT_I TXCT_MTH; run;

 

Aprreciate your help.thanks

 

Regards

RS

1 ACCEPTED SOLUTION

Accepted Solutions
1 REPLY 1
BaalaRaaji
Quartz | Level 8
Ignore it..I have resolved the issue..thanks

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 543 views
  • 0 likes
  • 1 in conversation