Answers

Question 1:

The answer is (b).

The IF statement keeps only the first observation in the X and Y BY group. There should be only seven observations in the output.

The Z variable contains the value (27) in the first observation of the (X=1, Y=A) group. As a result, (c) is not the correct answer.

Question 2:

The answer is (c).

The data step keeps only the first and last observations in each region. There are two observations for each region in the output.

Question 3:

The answer is (c).

The PAYROLL variable contains the total salaries for each department.​

Question 4:

The answer is (a).

The output data set contains only the last observation for each department. There are five departments in total and there are only five observations in the output.

Question 5:

The answer is (b).

The EMPDATA data set does not contain the SALARY variable from the SALARY data set. The variable must have been dropped in the data set.

Since the SALARY variable is used when calculating the TOTSAL variable in the data step, it must be dropped from the output data set, not the input data set. As a result, (c) is not the correct answer.

Question 6:

The answer is (b).

When no initial value is specified for the variable in the RETAIN statement, the variable is initiated with a missing value.