Base SAS 82

The SASDATA.BANKS data set has five observations when the following SAS program is submitted:
libname sasdata 'SAS-data-library';
data allobs;
set sasdata.banks;
capital=0;
do year = 2000 to 2020 by 5;
capital + ((capital+2000) * rate);
output;
end;
run;
How many observations will the ALLOBS data set contain?
A. 5
B. 15
C. 20
D. 25
Click Comment link to get answer

33 comments:

  1. Replies
    1. Anonymous10:34 AM

      roshini ur right baby

      Delete
  2. i think its C....2000 to 2020 by 5. so, 4 iterations..

    ReplyDelete
  3. Anonymous1:27 PM

    D

    year=2000 to 2020 by 5
    (includes the 2020 also, so 5 iterations)

    ReplyDelete
  4. sas user5:50 AM

    D

    2000
    2005
    2010 2015
    2020

    ReplyDelete
  5. Anonymous5:35 PM

    D
    5*5=25

    ReplyDelete
  6. D

    5 observations 5 iterations

    ReplyDelete
  7. Anonymous9:20 PM

    A is correct answer

    ReplyDelete
  8. because the output statement is inside the do loop, an observation will be created each time through the loop, so 5 observations, 5 loops, 25 observations total

    ReplyDelete
  9. sweta4:29 PM

    answers IS A.
    Because of output statement 5 observations are created otherwise only one.

    try the below SAS statement:-
    data allobs;
    rate=0.1;
    capital=0;
    do year = 2000 to 2020 by 5;
    capital + ((capital+2000) * rate);
    end;
    run;

    ReplyDelete
  10. Answer is D.

    data banks;
    input num;
    datalines;
    1
    2
    3
    4
    5
    ;
    run;

    data allobs;
    set banks;
    rate=0.1;
    capital=0;
    do year = 2000 to 2020 by 5;
    capital + ((capital+2000) * rate);
    output;
    end;
    run;

    NOTE: There were 5 observations read from the data set WORK.BANKS.
    NOTE: The data set WORK.ALLOBS has 25 observations and 4 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.01 seconds
    cpu time 0.02 seconds

    ReplyDelete
  11. Anonymous3:38 PM

    @ sweta,
    u missed d the explicit ouptput statement in the do loop. due to this explicit output staemnt in the do loop there will be 5 obsn for each obsn in the bank dataset, so the total of obsn in the new dataset allobs will be (5*5)=25
    >> joydeep786@gmail.com

    ReplyDelete
  12. ani ....4:43 PM

    ans is D its a good one .
    my mail
    lotlikar.aniket44@gmail.com

    ReplyDelete
  13. Anonymous4:37 PM

    Why are you guys giving out your email ids?? I don't anyone is interested in mailing dudes. Girls are most welcome to share their emails please. That behavior is highly encouraged.

    Answer is D. A good question after a long while.

    ReplyDelete
  14. Anonymous7:19 AM

    Shouldn't the answer be A?
    corrrect me if i'm wrong, but
    it's INOCREMENTED by 5.
    so 2000, 2005, 2010, 2015, 2020 (total of 5)

    for those who argue that it's 5obs*5iterarion
    isn't that the case when it's NESTED DO LOOP?

    correct me if i'm wrong.
    Thx in advance.

    ReplyDelete
  15. Ans is A....
    plz dont post without cross checking the ans...it will be confusing
    try this code :
    data allobs;
    rate = 0.5;
    capital=0;
    do year = 2000 to 2020 by 5;
    capital + ((capital+2000) * rate);
    output;
    end;
    run;
    proc print ;
    run;

    ReplyDelete
  16. Anonymous8:47 AM

    There was question and answer sheet on web it says 25 but trying to find why 25?
    SAScert;

    Can you give us the reasons for adding datelines;
    1
    2
    3
    4
    5
    ; why we need this ?
    Because increment by 5 thefefore we added 5 datalines?

    ReplyDelete
    Replies
    1. Anonymous4:26 PM

      Dude question says, dataset bank has 5 observations. If you take only one observation then A will be r8.

      Delete
  17. Anonymous2:45 AM

    D is right,we r copying one data set to another dataset.there were 5 observations and for each obs the loop runs one time. so for one obs it will take 5 iterations .... for better understanding use macros with MLOGIC option ....



    thank u
    Chiru

    ReplyDelete
  18. priyanka12:33 AM

    D is the right answer.

    the do loop will execute 5 times(2000,2005,2010,2015,2020)for each observation of the sasdata.banks data set.

    therefore,
    =5(observation of sasdata.bank)*5(times do loop execution)
    =25 !!

    ReplyDelete
  19. Anonymous12:21 PM

    Anyone who said anything other than D is wrong. Please try this code:
    Data employee;
    input id salary name$ location$12.;
    cards;
    101 8500 asim bangalore
    102 45 ravi chennai
    103 75236 chinna hyderabad
    104 899 siva US
    107 675 rajesh hubli
    run;

    data allobs;
    set employee;
    rate=0.1;
    capital=0;
    do year = 2000 to 2020 by 5;
    capital + ((capital+2000) * rate);
    output;
    end;
    run;

    Remove the output statement or put the output outside the do look. The allobs dataset will have 5 observations.

    ReplyDelete
  20. Ans is 5 its sad by 5 means every tme ts increment by 5 so only 5 observaton.

    ReplyDelete
  21. Ans : D

    Example :

    data banks;
    input rate;
    datalines;
    0.1
    0.2
    0.3
    0.4
    0.5
    ;
    run;

    data allobs;
    set banks;
    capital=0;
    do year = 2000 to 2020 by 5;
    capital + ((capital+2000) * rate);
    output;
    end;
    run;

    Proc Print;
    run;

    Log :



    145
    146 data banks;
    147 input rate;
    148 datalines;

    NOTE: The data set WORK.BANKS has 5 observations and 1 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.05 seconds
    cpu time 0.01 seconds


    154 ;
    155 run;
    156
    157 data allobs;
    158 set banks;
    159 capital=0;
    160 do year = 2000 to 2020 by 5;
    161 capital + ((capital+2000) * rate);
    162 output;
    163 end;
    164 run;

    NOTE: There were 5 observations read from the data set WORK.BANKS.
    NOTE: The data set WORK.ALLOBS has 25 observations and 3 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.13 seconds
    cpu time 0.04 seconds


    165
    166 Proc Print;
    167 run;

    NOTE: Writing HTML Body file: sashtml3.htm
    NOTE: There were 25 observations read from the data set WORK.ALLOBS.
    NOTE: PROCEDURE PRINT used (Total process time):
    real time 0.12 seconds
    cpu time 0.01 seconds

    ReplyDelete
  22. Out Put :

    Obs rate capital year
    1 0.1 200.00 2000
    2 0.1 420.00 2005
    3 0.1 662.00 2010
    4 0.1 928.20 2015
    5 0.1 1221.02 2020
    6 0.2 400.00 2000
    7 0.2 880.00 2005
    8 0.2 1456.00 2010
    9 0.2 2147.20 2015
    10 0.2 2976.64 2020
    11 0.3 600.00 2000
    12 0.3 1380.00 2005
    13 0.3 2394.00 2010
    14 0.3 3712.20 2015
    15 0.3 5425.86 2020
    16 0.4 800.00 2000
    17 0.4 1920.00 2005
    18 0.4 3488.00 2010
    19 0.4 5683.20 2015
    20 0.4 8756.48 2020
    21 0.5 1000.00 2000
    22 0.5 2500.00 2005
    23 0.5 4750.00 2010
    24 0.5 8125.00 2015
    25 0.5 13187.50 2020

    ReplyDelete
  23. Answer A. Proper answer: Depends on rate.

    @Zakku, why do you have five observations for rate? Not one or six? If we choose six observations for rate, the answer would be 30.

    In my view, we can assume a unique value for rate; the answer would be five (A).

    ReplyDelete
  24. what wa the answer?? why 25??

    ReplyDelete
    Replies
    1. 5 observations from input dataset, each observation is outputted 5 times by do loop, so 5*5 = 25 obs.

      Delete