SAS Base Programming for SAS 9 — Question 37

The following SAS program is submitted:
data work.accounting;
set work.dept1 work.dept2;
jobcode = FA1;
length jobcode $ 8;
run;
A character variable named JOBCODE is contained in both the WORK.DEPT1 and WORK.DEPT2 SAS data sets. The variable JOBCODE has a length of 5 in the
WORK.DEPT1 data set and a length of 7 in the WORK.DEPT2 data set. What is the length of the variable JOBCODE in the output data set?

Answer options

Correct answer: B

Explanation

The length of the JOBCODE variable in the output data set will be determined by the length specified in the DATA step, which is 8. However, since JOBCODE is being set to a value from the input data sets, the output length will be the maximum length from the input data sets, which in this case is 5 from WORK.DEPT1. Therefore, the correct answer is B, 5, as it is the shorter length of the two input sets.