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?
-
London
-
Copenh
-
Copenhagen
-
Missing
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).