The following SAS program is submitted:
data work.new;
length word $7;
amount = 7;
if amount = 5 then word = 'CAT';
else if amount = 7 then word = 'DOG';
else word = 'NONE!!!';
amount = 5;
run;
Which one of the following represents the values of the AMOUNT and WORD variables?
A. amount word
5 DOG
B. amount word
5 CAT
C. amount word
7 DOG
D. amount word
7 ' ' (missing character value)
Click Comment link to get answer
Answer is A
ReplyDeleteA
ReplyDeletea
ReplyDeleteA
ReplyDelete>>always "Dog" will be assigned to word as amount is hardcoded 7 in the begining of each iteration
>>and a value of 5 is saved in amount as it is hardcoded before the end of each output.
A
ReplyDeleteI dint understand the answer, Can anybody explain it?
ReplyDeleteThis question checks your knowledge about how sas reads. When SAS reads in the iterations in sequence, it first writes 5 to the variable 'amount'in PDV. Then it reads through the condition and writes 'DOG' for variable 'word' in PDV. Then it again encounters the value 7 and writes to 'Amount' in PDV. As this is not a loop and run statement follows, SAS gives the output from PDV which would be 7 and 'Dog'. Hopw this helps.
ReplyDeleteThis comment has been removed by the author.
DeleteSorry for the above explanation, Please read in the values for 'amount' as 7 and 5 respectively. Hence the answer would be 'A'.
ReplyDeleteA
ReplyDeleteA
ReplyDeleteA
ReplyDeletea
ReplyDeleteA
ReplyDeleteI really like how you have explained various concepts here. Can anyone plz guide me regarding where to find short questions just like asked in SAS Base exam for practice? The kind of questions where we need to right the code and answer multiple questions based on it?
ReplyDeleteThis blog gives very important info about SAS Thanks for sharing. Very well written information.
ReplyDeleteSAS Certification
SAS Certification course