general cert question

Accepted Solution Solved
Reply
Valued Guide
Posts: 860
Accepted Solution

general cert question

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


Accepted Solutions
Solution
‎02-01-2013 03:57 PM
Super Contributor
Posts: 1,636

Re: general cert question

Posted in reply to Steelers_In_DC

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;

View solution in original post


All Replies
Super Contributor
Posts: 578

Re: general cert question

Posted in reply to Steelers_In_DC

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.

Respected Advisor
Posts: 3,799

Re: general cert question

Posted in reply to Steelers_In_DC

It is due to the placement of the OUTPUT statement.  5 obs output for each obs in SASDATA.BANKS.

Solution
‎02-01-2013 03:57 PM
Super Contributor
Posts: 1,636

Re: general cert question

Posted in reply to Steelers_In_DC

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;

Valued Guide
Posts: 860

Re: general cert question

Thanks, spelling it out like that helped a great deal.  Running the program and looking at the log/output always helps.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 391 views
  • 3 likes
  • 4 in conversation