BookmarkSubscribeRSS Feed
pankak
Calcite | Level 5

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.



3 REPLIES 3
Reeza
Super User

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;

Steelers_In_DC
Barite | Level 11

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;

naveen20jan
Obsidian | Level 7

Hi  ,

Could you please eloborate the query a bit.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1121 views
  • 0 likes
  • 4 in conversation