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
Topics:
SAS Base Questions |
12 Comments »
D
it should be C i.e. 7 bec it will never enter in to loop..
correct me if i m wrong!!
it checks the condition at the bottom of the loop, so the value 8 is written to the dataset
DO UNTIL evaluates at the end of the loop.
7 enters the loop once, and 7+1=8.
D is right.
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.
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.
do loop executes once before validating the condition…
@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.
7 is greater than 6, and it will loop once more to 8.
do until check the condition AFTER
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
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.