Question : The following SAS program is submitted:
libname sasdata 'SAS-data-library'; data test; set sasdata.chemists; if jobcode = 'Chem2' then description = 'Senior Chemist'; else description = 'Unknown'; run; A value for the variable JOBCODE is listed below: JOBCODE chem2 Which one of the following values does the variable DESCRIPTION contain?
is it because of the case of the string chem2 instead of Chem2. If is case sensitive and considers if jobcode = 'Chem2' as false. 'unknown is the answer. Chem2 is in inverted comma. if any word is in inverted comma than sas will be case sensitive for that word.
Question : 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?
1. Other 2. Copenh 3. Copenhagen 4. ' ' (missing character value)
Correct Answer :1 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 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.
Question :
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?
1. London 2. Copenh 3. Copenhagen 4. ' ' (missing character value)
Correct Answer : 2
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.