SAS Base (53)

The following SAS program is submitted:

retain Total;
by Department;
if First.Department
then Total=0;
Total=sum(Total, Wagerate);
if Last.Total;

What is the initial value of the variable Total?

A. 0
B. Missing
C. The value of the first observations Wagerate
D. Cannot be determined from the information given

Check Answer
Answer: B

注解:The second line of codes, retain Total, initializes the variable Total.  As it doesn’t specify an initial value, a missing value is assigned to the variable. Please also check SAS Base (32) for the details of RETAIN statement.

2 thoughts to “SAS Base (53)”

  1. 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.

    1. Like retain Total 0; then initial value of Total is 0. But in this case, there is no “0” so that it is missing value.

Leave a Reply

Your email address will not be published. Required fields are marked *