Base SAS Certification Questions and important concepts needed to ace the exams.
ElearnSAS.com
SAS Learning Platform
Base SAS 35
The following SAS program is submitted: data work.pieces; do while (n lt 6); n + 1; end; run; Which one of the following is the value of the variable N in the output data set? A. 4 B. 5 C. 6 D. 7 Click Comment link to get answer
Similar to last question, DO WHILE (evaluates at the top of the loop). [Remember: SAS gives value starting from 0, if value not defined] n=0, 1, 2, 3, 4, 5 than n is lt (less than) 6 therefore n lt 6 is TRUE. DO LOOP is executed. Adding plus 1 at every iteration. Now, when n=6 at top, it is not less than 6 therefore condition n lt 6 is FALSE. DO LOOP is not executed. Hence, the value of n remains 6
because of n+1 statement we assume a implicit retain n 0; statment. First loop (0 lt 6) => true => n = 1 Second loop (1 lt 6) => true => n= 2 ...... last loop (6 lt 6) => false => do while exits and pdv writes 6 as value of n in output dataset. Hopefully that helps.
data pieces; do while (n lt 6); n + 1; end; run; proc print data=pieces; run; it will take n as 1 and loop 5 times to get 5 which is less then 6. then add 5+1=6. put 4 inplace of 1 n c u will get 8 that becose it loops once n give 4 so 4+4 gives 8 put 2 inplace of 1 n c. it will loop twice to give 4 and 4+2 is 6 so ans is 6 .. i am great na...
In question (34) calls= 6; do while ( call le 6) calls+1 end; run; in Question (35) do while (n lt 6); n + 1; end; run; Please someone explain the differences? in Q 34 , calls= 6 and when it reads calls takes the value 6 and adds 1 gives us the result 7, no more do loops stops there because in next iteration calls will be greater than 6.a Am I correct? but in Q35 n is not given rather it is in the do loops and reads 5 and adds 1 = 6, next loop it is equal to 6, stops the iteration. VOILA!!!!!!!!, Please correct me if I am wrong.
C
ReplyDeleteC
ReplyDeleteANSWER IS C FOR SURE
ReplyDeletehow it is C ? can u expalain?
ReplyDeleteSimilar to last question, DO WHILE (evaluates at the top of the loop). [Remember: SAS gives value starting from 0, if value not defined] n=0, 1, 2, 3, 4, 5 than n is lt (less than) 6 therefore n lt 6 is TRUE. DO LOOP is executed.
DeleteAdding plus 1 at every iteration.
Now, when n=6 at top, it is not less than 6 therefore condition n lt 6 is FALSE. DO LOOP is not executed.
Hence, the value of n remains 6
because of n+1 statement we assume a implicit retain n 0; statment.
ReplyDeleteFirst loop (0 lt 6) => true => n = 1
Second loop (1 lt 6) => true => n= 2
......
last loop (6 lt 6) => false => do while exits and pdv writes 6 as value of n in output dataset. Hopefully that helps.
c carefully.....
ReplyDeleteans is c-6.
data pieces;
do while (n lt 6);
n + 1;
end;
run;
proc print data=pieces;
run;
it will take n as 1 and loop 5 times to get 5 which is less then 6. then add 5+1=6.
put 4 inplace of 1 n c u will get 8 that becose it loops once n give 4 so 4+4 gives 8
put 2 inplace of 1 n c. it will loop twice to give 4 and 4+2 is 6 so ans is 6 .. i am great na...
Folks:
ReplyDeleteIn question (34)
calls= 6;
do while ( call le 6)
calls+1
end;
run;
in Question (35)
do while (n lt 6);
n + 1;
end;
run;
Please someone explain the differences?
in Q 34 , calls= 6 and when it reads calls takes the value 6 and adds 1 gives us the result 7, no more do loops stops there because in next iteration calls will be greater than 6.a Am I correct?
but in Q35 n is not given rather it is in the do loops and reads 5 and adds 1 = 6, next loop it is equal to 6, stops the iteration. VOILA!!!!!!!!,
Please correct me if I am wrong.
lt = "less than"
ReplyDeletele = "less than or equal to"
D
ReplyDeleteB
ReplyDeleteThe ans is 6 (C) in this case. Nice expln given by some one already abt implicit retain as n+1
ReplyDeleteC
ReplyDeleteThis is just the information I am finding everywhere. Thanks for your blog, I just subscribe your blog. This is a nice blog..
ReplyDelete50 Niche Relevant Blog Comment High Quality
Hello!! I'am glad to read the whole content of this blog and am very excited.Thank you.
ReplyDeleteตารางคะแนน
All you need to be aware in this case is knowing the following difference:
ReplyDeletelt means 'less than <'
le means 'less or equal to <='
same can be said for > , >=
gt ' greater than'
ge 'greater than or equal to'.
Hope it helps
C
ReplyDelete