ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 64

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

27 comments:

  1. Anonymous11:58 AM

    Imp to note
    if destination = 'CPH';

    then answer will be Copenh

    ReplyDelete
  2. Anonymous7:40 PM

    Yeah, B is correct.

    ReplyDelete
  3. Anonymous7:43 PM

    oh, sorry, the answer is A, care about the capital CPH is in the when statement.

    ReplyDelete
  4. Anonymous3:53 PM

    cph is note = to CPH

    I think the answer is A

    ReplyDelete
  5. Anonymous7:50 PM

    exact match only

    ReplyDelete
  6. Anonymous6:19 PM

    Would think A because the literal lowercase 'cph' does NOT match the uppercase 'CPH'? If not, please explain; thanks.

    ReplyDelete
  7. Anonymous12:08 PM

    This is out of a Sas reference book I have. It is talking about an example with the Select() function.

    Note 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.

    ReplyDelete
  8. Anonymous2:31 PM

    run the code and you ll its A as CPH ne cph

    ReplyDelete
  9. Anonymous7:33 AM

    Usha is wrong most of the times. I dont know why she even comments and confuse everyone.

    ReplyDelete
    Replies
    1. Anonymous8:22 PM

      hahahaha

      Delete
    2. Anonymous10:46 PM

      lol

      Delete
    3. Anonymous4:29 PM

      Everybody is trying his or her best. There is always sth that you don't know but somebody else knows. So why laugh at Usha?

      Delete
  10. Anonymous1:22 PM

    Usha is really stupid

    ReplyDelete
    Replies
    1. Anonymous4:31 PM

      No bullying, guys!

      Delete

  11. Obs destination city
    Here is SAS output
    1 CPH Copenh
    Answer is B

    ReplyDelete
  12. data work.flights;
    destination = '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

    ReplyDelete
  13. This comment has been removed by the author.

    ReplyDelete
  14. This comment has been removed by the author.

    ReplyDelete
  15. Anonymous9:02 PM

    THE ANSWER IS A

    ReplyDelete