The following SAS program is submitted:
data work.flights;
destination = 'cph';
select(destination);
when('LHR') city = 'London';
when('CPH') city = 'Copenhagen';
otherwise city = 'Other';
end;
run;
Which one of the following is the value of the CITY variable?
A. Other
B. Copenh
C. Copenhagen
D. ' ' (missing character value)
Click Comment link to get answer
A
ReplyDeleteImp to note
ReplyDeleteif destination = 'CPH';
then answer will be Copenh
Yeah, B is correct.
ReplyDeleteoh, sorry, the answer is A, care about the capital CPH is in the when statement.
ReplyDeleteB
ReplyDeleteA
ReplyDeletecph is note = to CPH
ReplyDeleteI think the answer is A
exact match only
ReplyDeleteWould think A because the literal lowercase 'cph' does NOT match the uppercase 'CPH'? If not, please explain; thanks.
ReplyDeleteThis is out of a Sas reference book I have. It is talking about an example with the Select() function.
ReplyDeleteNote Notice that the LENGTH statement in the DATA step above specifies a length
of 20 for Group. Remember that without the LENGTH statement, values for
Group might be truncated, as the first value for Group (Flight Attendant I) is
not the longest possible value.
Warning When you are comparing values in the when-expression, be sure to
express the values exactly as they are coded in the data. For example, the
281
when-expression below would be evaluated as false because the values for
JobCode in Sasuser.Payrollmaster are stored in uppercase letters.
when ("fa1") group="Flight Attendant I";
In this case, given the SELECT group above, Group would be assigned
the value Other.
Based on this, the answer would be Copenh (choice B)due to omitting a length statement, but the answer is actually going to be Other (choice A) because 'cph' and When ('CPH') do not agree in case.
run the code and you ll its A as CPH ne cph
ReplyDeleteUsha is wrong most of the times. I dont know why she even comments and confuse everyone.
ReplyDeletehahahaha
Deletelol
DeleteEverybody is trying his or her best. There is always sth that you don't know but somebody else knows. So why laugh at Usha?
DeleteUsha is really stupid
ReplyDeleteNo bullying, guys!
DeleteObs destination city
Here is SAS output
1 CPH Copenh
Answer is B
A
ReplyDeleteA
ReplyDeletedata work.flights;
ReplyDeletedestination = 'cph';
select(destination);
when('LHR') city = 'London';
when('CPH') city = 'Copenhagen';
otherwise city = 'Other';
end;
run;
proc print data=work.flights;
run;
answer is A
A
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteTHE ANSWER IS A
ReplyDeleteA
ReplyDeleteA
ReplyDelete