BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Steelers_In_DC
Barite | Level 11

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

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10

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

4 REPLIES 4
DBailey
Lapis Lazuli | Level 10

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.

data_null__
Jade | Level 19

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

Linlin
Lapis Lazuli | Level 10

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;

Steelers_In_DC
Barite | Level 11

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

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
  • 4 replies
  • 819 views
  • 3 likes
  • 4 in conversation