Multiple choice technology programming languages

The following SAS program is submitted: data work.flights; destination='CPH'; select(destination); when('LPR') city = 'London'; when('CPH') city='Copenhagen'; otherwise; end;run; Which one of the following is the value of the CITY variable?

  1. London

  2. Copenh

  3. Copenhagen

  4. Missing

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The SELECT statement uses case-sensitive matching. The destination variable contains 'CPH', but the WHEN clause checks for 'CPH' which matches, so city is assigned 'Copenhagen'. However, SAS character variables are truncated to their defined length, and without a LENGTH statement, the default length of 8 characters applies. 'Copenhagen' is truncated to 'Copenh' (8 chars).