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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

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
  • 3 replies
  • 880 views
  • 0 likes
  • 4 in conversation