**Question 8:** This question will ask you to provide a line of missing code.

Given the following data set WORK.SALES:

SalesID SalesJan FebSales MarchAmt
------- -------- -------- --------
W6790 50 400 350
W7693 25 100 125
W1387 . 300 250

The following SAS program is submitted:

1
2
3
4
5
| data WORK.QTR1;
set WORK.SALES;
array month{3} SalesJan FebSales MarchAmt;
<insert code here>
run; |

data WORK.QTR1;
set WORK.SALES;
array month{3} SalesJan FebSales MarchAmt;
<insert code here>
run;

Which statement should be inserted to produce the following output?

SalesID SalesJan FebSales MarchAmt Qtr1
------- -------- -------- -------- ----
W6790 50 400 350 800
W7693 25 100 125 250
W1387 . 300 250 550

**Options:**

A. Qtr1 = sum(of month{_ALL_});
B. Qtr1 = month{1} + month{2} + month{3};
C. Qtr1 = sum(of month{*});
D. Qtr1 = sum(of month{3});

**The SAS certification sample problem and answer above are sourced from the official SAS sample questions page. All answer logs, data sets, output, and commentary are provided by this blog.*

Click to see Answer Explanation below
**Data set: **

WORK.QTR1:

** Commentary:**

Paul Dickman has a concise explanation of the SUM function:

http://www.pauldickman.com/teaching/sas/functions.php

An excerpt from his page:

The following are all valid arguments for the SUM function:
sum(of variable1-variablen) where n is an integer greater than 1
sum(of x y z)
sum(of array-name{*})
sum(of _numeric_)
sum(of x--a) where x precedes a in the PDV order

In this example, we are simply using the third argument of the SUM function in SAS, which nicely handles the NULL value in the third observation. In the answers provided above, using choice B will result in a NULL value for *Qtr1* on the third observation (again the SUM function takes care of this). Choice D will simply give the sum of the third array element (in this case *MarchAmt*). Choice A cannot be used because _ALL_ cannot be used as a variable name and is generally a keyword used in options (e.g. with proc datasets).

I did not understand the 4 th and 5th arguments how does it work? Can you give me an example? Thank you

I mean the explanation is given for this question and He mentioned 5 valid arguments about sum function.

Refer to the Paul Dickman Sum website mentioned in Commentary prior to the 5 arguments! Good Luck