**Question 1:** The following SAS program is submitted:

1
2
3
4
5
6
7
| data test;
set sasuser.employees;
if 2 le years_service le 10 then amount = 1000;
else if years_service gt 10 then amount = 2000;
else amount = 0;
amount_per_year = years_service / amount;
run; |

data test;
set sasuser.employees;
if 2 le years_service le 10 then amount = 1000;
else if years_service gt 10 then amount = 2000;
else amount = 0;
amount_per_year = years_service / amount;
run;

Which one of the following values does the variable AMOUNT_PER_YEAR contain if an employee has been with the company for one year?

**Options:**

A. 0
B. 1000
C. 2000
D. . (missing numeric value)

**This blog is not affiliated with SAS or the SAS Institute. All answer logs, data sets, output, and commentary are provided by this blog.*

Click to see Answer Explanation below
**Log: **

29 data test;
30 set sasuser.employees;
31 if 2 le years_service le 10 then amount = 1000;
32 else if years_service gt 10 then amount = 2000;
33 else amount = 0;
34 amount_per_year = years_service / amount;
35 run;
NOTE: Division by zero detected at line 34 column 33.
Name=Merry years_service=1 amount=0 amount_per_year=. _ERROR_=1 _N_=4
NOTE: Mathematical operations could not be performed at the following places. The results of the
operations have been set to missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 34:33
NOTE: There were 5 observations read from the data set SASUSER.EMPLOYEES.
NOTE: The data set WORK.TEST has 5 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.10 seconds
cpu time 0.06 seconds

** Data Set(s):**

** Commentary:**

For the fourth observation, *years_service* is 1 and *amount* is 0. When the formula for *amount_per_year* is applied, the result for this observation yields 1/0 for *years_service/amount* (divide by zero occurs). The automatic variable _ERROR_ set to 1 since this result is technically infinity. However, there is no numeric value to represent infinity in SAS, so it assigns a missing value to *amount_per_year*.

Please note that this problem has a bit of a typo (no space after the set statement). A correction might make the question more clear. Thanks!