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.

Leave a Reply

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