ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

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

46 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. Anonymous5: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. Anonymous10:36 PM

    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
    Replies
    1. Anonymous12:08 PM

      hi im just confused why 5 iteration for each obs? i know its bcuz of the output in the do loop......but is it bczu of the by 5 or sth so that each obs get 5 output?

      Delete
  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
    Replies
    1. Anonymous12:11 PM

      why 5 iterations for each obs.....bcuz of the by 5?

      Delete
  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
    Replies
    1. Anonymous12:12 PM

      why 5 times for each obs? not 1 or some different number?

      Delete
  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
  25. Anonymous12:14 PM

    sorry all but im just confused why is it 5 iteration for each obs bcuz of the output in do loop; not a different number of iteration?

    ReplyDelete
  26. An understanding of PDV can clear the doubts of all who are confused. Ans is D

    ReplyDelete

  27. THE CORRECT ANSWERS IS A..

    RUN THE BELOW MENTIONED CODING AND YOU WILL GET THE ANSWER

    IF THE OUTPUT IS OUTSIDE THE LOOP ONLY ONE OBSERVATION COMES OUT.

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




    36 data allobs;
    37
    38 capital=0;
    39 do year = 2000 to 2020 by 5;
    40 capital + ((capital+2000) * rate);
    41 output;
    42 end;
    43 run;

    NOTE: Variable rate is uninitialized.
    NOTE: Missing values were generated as a result of performing an operation on missing values.
    Each place is given by: (Number of times) at (Line):(Column).
    5 at 40:27
    NOTE: The data set WORK.ALLOBS has 5 observations and 3 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.04 seconds
    cpu time 0.06 seconds

    ReplyDelete
  28. remove the set statement from it it will still give the same no of iterations

    ReplyDelete
  29. ans is d.

    Try this code

    proc sql;
    create table work.banks (
    rate integer,
    Var2 varchar(30));

    insert into work.banks values (10, 'one');
    insert into work.banks values (20, 'two');
    insert into work.banks values (1, 'three');
    insert into work.banks values (4, 'four');
    insert into work.banks values (8, 'five');
    quit;

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

    ReplyDelete
  30. Anonymous4:17 AM

    If you read the question again carefully, u can see '~has five observations'. So 5(five observations)*5(from do loop)=25

    ReplyDelete
  31. Really cool post, highly informative and professionally written and I am glad to be a visitor of this perfect blog, thank you for this rare info!
    SAS Online Training
    R Programming Online Training|
    Tableau Online Training|

    ReplyDelete
  32. Such an ideal piece of blog. It’s quite interesting to read content

    like this. I appreciate your blog Tableau Online Training

    ReplyDelete
  33. The JSM (Friday-Saturday-Sunday) Alfamart promo has been published, but is valid until Tuesday next week. Yes, this JSM Alfamart promo lasts for a long period, namely 7-9 August 2020. Who knows, the items in the JSM Alfamart promo catalog are suitable for your needs. Alfamart is one of the leading minimarket networks, regularly publishing JSM promo price catalogs for its customers. If you are one of the many customers who are waiting for the JSM Alfamart promo catalog, here are some items in the JSM Alfamart promo catalog that you can look at. Also Read: Fun! There is a special Dufan entrance ticket promo for independence The JSM Alfamart promo catalog is an opportunity for customers to get daily necessities at lower prices than usual. In fact, some people make the JSM Alfamart promo catalog a wholesaler of goods to be sold again. However, of course, there is nothing wrong with comparing the JSM Alfamart promo catalog with promo prices from other minimarkets, including the nearest neighboring stalls. JSM Alfamart promo prices and other modern minimarket JSM promo programs are not the only factors that can be considered shopping. Also Read: 'Two Weekly' Hypermart Promo for August 6 - 19 2020, just released! Being able to bargain and be able to chat with sellers is sometimes a valuable reason to beat price promos when shopping for household needs. Well, we can only get all of that from the nearest shops that are open in our neighborhood.

    ReplyDelete