BookmarkSubscribeRSS Feed
Nyioves
Calcite | Level 5

Eg 1.

data compound;

     Amount=50000;

     Rate1=.075;

     Yearly=Amount*Rate1;

     do i=1 to 12;

         Monthly+((Monthly+Amount)*(Rate1/12);

end;

run;

proc print data=compound; run;

output:

O  Amt     Rate1 Yrly    Mnthly

1500000.07537501261.77

Why isn't I = 13 in the  output?

Eg 2.

Here yearly does in fact show in the output and is incremented +1 _n_ ....

data invest;

     Capital=0;

     do Year=2001 to 2003;

             Capital=5000;

             Capital+(Capital*.075);

end;

run;

proc print data = invest; run;

Output:

O Cap   Yr

153752004
3 REPLIES 3
Tom
Super User Tom
Super User

Because the typo in the first data step makes it not run.  So it didn't overwrite the previous version of the data set named COMPOUND.

1244           Monthly+((Monthly+Amount)*(Rate1/12);

                                                   -

                                                   79

ERROR 79-322: Expecting a ).

Nyioves
Calcite | Level 5

That is correct.

ballardw
Super User

BTW you may want to investigate financial functions in the SAS help. They can save a lot of coding for common calculations.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 890 views
  • 1 like
  • 3 in conversation