Good Afternoon All, It's been a while since I've posted. I'm studying for the base sas certification and depending on who I talk to it's either very easy or impossible. I'm doing my best to gather study info from the interwebs, what sas provides seems like a lot of softballs compared to what the practice exams online look like. I came across the following and don't understand it. If you can help I'd appreciate it, any additional info regarding preparing for the certification is welcome also.
Thanks,
Why does the following contain 25 observations:
data allobs;
set sasdata.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
Mark
the do loop outputs five times and there must be five observations in the dataset sasdata.backs. 5*5=25
data banks;
input rate;
cards;
.05
.06
.07
.08
.09
;
data allobs;
set banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
proc print;run;
I don't have a sasdata.banks, but I suspect it has 5 observations in it For each observation, the loop is executed 5 times so 5 * 5=25.
It is due to the placement of the OUTPUT statement. 5 obs output for each obs in SASDATA.BANKS.
the do loop outputs five times and there must be five observations in the dataset sasdata.backs. 5*5=25
data banks;
input rate;
cards;
.05
.06
.07
.08
.09
;
data allobs;
set banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
proc print;run;
Thanks, spelling it out like that helped a great deal. Running the program and looking at the log/output always helps.
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.