DATA Step, Macro, Functions and more

write a code

Reply
Occasional Contributor
Posts: 11

write a code

In a fixed term deposit of 25 years calculate the total amount at the end of term with initial
amount of 5,00,00 and annual interest rate of 7% i) compounded annually II) compaunded monthly. show the amount accured at monthly level.

Super User
Posts: 6,936

Re: write a code

Please show the code you already tried, and where the result differed from your expected result.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 11

Re: write a code

I have not started yet. Please write code.

Super User
Posts: 6,936

Re: write a code

My hourly fee for doing other people's work is 50 Euros. Can I send you my IBAN?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
PROC Star
Posts: 172

Re: write a code

Hi, I'm afraid your question doesn't sound like or request that essentially is a favor and rather that sounds like an order in a open public technical forum which is unfair. Please rephrase with some courtesy and kindess, you are more likely to get any kind of help you need. I am only suggesting, and do not take this personal. Thank you and have a nice day!

Occasional Contributor
Posts: 11

Re: write a code

I am really sorry for your thoughts. I just started doing programming in SAS, thats why I posted this question and need a clue to start writing code. I did not know the protocol of this forum. If my question hurts anyone in this forum, I am saying sorry for that, no other intention.

 

Super User
Posts: 5,256

Re: write a code

If you are new to SAS programming, I would suggest that you take the free online Programming 1 course. It will help develop your skills, and hopefully be able to direct more specific question on these forums in the future.

Data never sleeps
Super User
Posts: 6,936

Re: write a code

Hints:

In a data step, use a do loop. Set the initial amount before the loop. Calculate the increase in the loop (variable asssignment with simple mathematical formula), and use output to write a record (observation) to the target dataset.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,500

Re: write a code

Look in the online help for SAS functions such as FINANCE.

Super User
Posts: 9,681

Re: write a code

If I was right.


data _null_;
year=0.07;
month=0.07/12;

do i=1 to 25;
 year_amount=50000*constant('e')**(year*i);
 put 'year=' i ' year amount=' year_amount;
end;

do i=1 to 25*12;
 month_amount=50000*constant('e')**(month*i);
 put 'month=' i ' month amount=' month_amount;
end;
run; 


Occasional Contributor
Posts: 11

Re: write a code

Hello,

 

Thanks for your reply.

while running the below code, I am getting following output.

year_amount=287730.13

and month_amount=287730.13

 

 

but calculation formula used in the code for year_amount and month_amount is differenet while output is same for both year_amount and month_amount.

Super User
Posts: 9,681

Re: write a code

Can you show us the formula and the output ?


Occasional Contributor
Posts: 11

Re: write a code

I used the code sent by you.

Super User
Posts: 9,681

Re: write a code

I mean the formula for compounded interest annually and monthly .



Super User
Posts: 9,681

Re: write a code

So you want sparse compound interest ,not continuous compound.



data _null_;
year=0.07;
month=0.07/12;

year_amount=50000;
do i=1 to 25;
 year_amount=year_amount*(1+year);
 put 'year=' i ' year amount=' year_amount;
end;

month_amount=50000;
do i=1 to 25*12;
 month_amount=month_amount*(1+month);
 put 'month=' i ' month amount=' month_amount;
end;
run; 

Ask a Question
Discussion stats
  • 19 replies
  • 322 views
  • 7 likes
  • 7 in conversation