I have a dataset:
id_acc info_date ov_credit ov_debit account_balance interest_rate_anuual
111 30june2007 500 700 6000 0.18%
111 31jul2007 500 600 6008 0.18%
111 31aug2007 500 200 8000 0.18%
111 30sep2007 300 100 7000 0.18%
111 31oct2007 400 300 9000 0.18%
111 30nov2007 200 400 10000 0.18%
I want the ouput in the following manner.Please suggest ome logic
account_bal1=account_balance+sum(ov_debit ,-ov_credit )+interest_rate_anuual;
account_bal2=account_bal1+sum(ov_debit ,-ov_credit )+interest_rate_anuual;
account_bal3=account_bal2+sum(ov_debit ,-ov_credit )+interest_rate_anuual;
Please suggest some logic.
Use RETAIN
I doubt yoor formula is quite correct though, but I'm also not 100% sure of what you're doing.
retain account_bal;
if _n_=1 then account_bal=account_balance;
account_bal=account_bal+sum(ov_debit,ov_credit )+interest_rate_anuual;
data have;
infile cards dsd;
informat info_date date9.;
format info_date date9.;
input id_acc $ info_date $ ov_credit ov_debit account_balance interest_rate_anuual;
cards;
111,30jun2007,500,700,6000,0.18
111,31jul2007,500,600,6008,0.18
111,31aug2007,500,200,8000,0.18
111,30sep2007,300,100,7000,0.18
111,31oct2007,400,300,9000,0.18
111,30nov2007,200,400,10000,0.18
;
run;
data want;
set have;
account_bal1 = sum(account_balance,ov_debit,-ov_credit,interest_rate_anuual);
if not missing(account_bal1) then account_bal2 = sum(account_bal1,ov_debit,-ov_credit,interest_rate_anuual);
if not missing(account_bal2) then account_bal3 = sum(account_bal2,ov_debit,-ov_credit,interest_rate_anuual);
run;
Hi ,
Could you please eloborate the query a bit.
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.