By admin | August 6, 2009

SAS Certified Base Programmer 50 Questions (22)

The following SAS program is submitted:

data work.inventory;
    products=7;
    do until (products gt 6);
        products+1;
    end;
run;

Which one of the following is the value of the variable products in the output data set?

a. 5
b. 6
c. 7
d. 8

12 comments | Add One

  1. admin - 08/9/2009 at 8:34 pm

    D

  2. Anuja - 06/22/2011 at 3:04 pm

    it should be C i.e. 7 bec it will never enter in to loop..
    correct me if i m wrong!!

  3. vamsi - 09/10/2011 at 5:26 pm

    it checks the condition at the bottom of the loop, so the value 8 is written to the dataset

  4. Mina Zhou - 03/5/2012 at 1:09 pm

    DO UNTIL evaluates at the end of the loop.
    7 enters the loop once, and 7+1=8.
    D is right.

  5. xyz - 04/24/2012 at 11:08 pm

    Correct answer: ddd
    A DO UNTIL loop always executes at least once because the condition
    is not evaluated until the bottom of the loop. In the SAS program above, the
    value of Products is incremented from 7 to 8 on the first iteration of the DO
    UNTIL loop, before the condition is checked. Therefore the value of Products
    is 8.You can learn about DO UNTIL loops in Generating Data with DO Loops.

  6. Vinu - 05/23/2012 at 4:07 pm

    The answer is D because Do Until condition is evaluated at the bottom of the loop, so the enclosed statements are always executed at least once.

  7. sachin - 07/21/2012 at 10:29 pm

    do loop executes once before validating the condition…

  8. Anand - 09/28/2012 at 11:18 am

    @Anuja. In a DO UNTIL loop, the condition is checked at the bottom of the loop.So the loop will execute at least once.So the value of the variable products in the output dataset is 8.

  9. Evan - 10/1/2012 at 2:41 pm

    7 is greater than 6, and it will loop once more to 8.

  10. cle - 10/10/2012 at 4:09 pm

    do until check the condition AFTER

  11. Nik - 03/11/2013 at 11:38 am

    It’s D, because
    A DO WHILE statement processes a loop as long as a condition is true; a DO UNTIL statement processes a loop until a condition is true, but a DO UNTIL loop always processes at least once

  12. Aman - 01/15/2014 at 6:21 am

    The answer is D because it enters the loop at least once if the condition is true at the beginning of the loop.
    if the condition is not true at the Beginning then it will not execute for the true condition when it founds.

Leave a Comment

Leave a Reply

Your email address will not be published.