BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi All,

Kindly could anyone suggest how do we get to the output as below using the codesn 1. and 2. :


1.

data invest (drop =i);
do i=1 to 3;
capital+2000;
capital+capital*.1;
end;
run;


Output is: Capital=7282


2.

data invest (drop =year);
do year=1 to 3;
capital+2000;
do month=1 to 3;
Interest=capital*(0.075/12);
end;
end;
run;


Output : Capital=6000, Month=4, Interest=37.5


Kind Regards,
Kriti
2 REPLIES 2
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You need to add an explicit OUTPUT statement inside your DO/END loop.

Scott Barry
SBBWorks, Inc.

Suggested Google advanced search argument, this topic / post:

data step do loop output site:sas.com
ChrisNZ
Tourmaline | Level 20
Unsure what you want to achieve, but rather then an output statement, maybe you want to add a
[pre]put _ALL_;[/pre]
statement before run; ?

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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