ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 65

The following SAS program is submitted:
data work.flights;
destination = 'CPH';
select(destination);
when('LHR') city = 'London';
when('CPH') city = 'Copenhagen';
otherwise;
end;
run;
Which one of the following is the value of the CITY variable?
A. London
B. Copenh
C. Copenhagen
D. ' ' (missing character value)
Click Comment link to get answer

28 comments:

  1. Anonymous7:34 AM

    I think its B

    ReplyDelete
  2. Anonymous12:03 PM

    see
    city = 'London' - Length of assignment.

    Second assignment
    when('CPH') city = 'Copenhagen';
    will cut down the words.

    Answer will be Copenh

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

    ReplyDelete
  4. Anonymous11:28 AM

    Notice that the LENGTH statement in the SELECT group has not been specified. Remember that without the LENGTH statement, values for Group might be truncated, as the first value for Group (London) is not the longest possible value.

    So, the answer is B.

    Ferrat

    ReplyDelete
  5. Anonymous5:16 PM

    length没制定city,默认为london的长度--6位

    ReplyDelete
    Replies
    1. Anonymous1:54 PM

      啧啧,不用英文

      Delete
    2. Anonymous4:34 PM

      头一次看见中文,呵呵!

      Delete
    3. Anonymous2:41 PM

      哈哈哈 求多多发言!

      Delete
    4. Anonymous1:02 AM

      kanji?

      Delete
    5. Anonymous10:29 AM

      感觉比印度朋友的解释简洁很多,开心

      Delete
    6. Anonymous9:01 PM

      谢谢老哥。

      Delete
  6. Anonymous12:41 AM

    инглиш плиз

    ReplyDelete
  7. Anonymous6:38 PM

    धन्यबाद सुकृया , सत्सृकाल

    ReplyDelete
  8. Anonymous3:58 AM

    data work.flights;
    99 destination = 'CPH';
    100 select(destination);
    101 when('LHR') city = 'London';
    102 when('CPH') city = 'Copenhagen';
    103 otherwise;
    104
    105 end;
    106 put city= ;
    107 run;

    city=Copenh

    ReplyDelete
  9. Anonymous10:17 PM

    Thanks Ferat for your quality explanation. B it is.

    ReplyDelete
  10. Here is the SAS output

    Obs destination city

    1 CPH Copenh
    Answer is B because of the first occurrence of LONDON, 6 chars,

    ReplyDelete
  11. data work.class;
    set sashelp.class(keep=name age);
    if age>=13 then group='Teen';
    if 11<=age<=13 then group='Pre-Teen';
    run;

    what is the output if age is 13

    ReplyDelete
    Replies
    1. Anonymous3:02 PM

      Pre-
      Because group length set to 4 first(Teen),so in the next condition it will read only 4 characters

      Delete
  12. Ans is D;
    Which one of the following is the value of the CITY variable?
    in ques. City variable mention as CITY & variable name would be case sensitive


    ReplyDelete
    Replies
    1. The ans would be B. Copenh.
      Because length of a variable is assigned to PDV as per its first appearance. And so variable (city) will have a length of 6 characters(because london has 6 characters).

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

    ReplyDelete