SAS Certified Base Programmer 50 Questions (18)
A raw data file is listed below.
1---+----10---+----20---+--- 10 23 20 15
The following program is submitted:
data all_sales; infile 'file-specification'; input receipts; <insert statement(s) here> run;
Which statement(s) complete(s) the program and produce(s) a running total of the Receipts variable?
a.
total+receipts;
b.
total 0;
sum total;
c.
total=total+receipts;
d.
total=sum(total,receipts);
Topics:
SAS Base Questions |
6 Comments »
A
Why not C or D?
A and D both are correct. I tried it. Try yourself.
You’ll get missing for c or d. Not sure why exactly. I learned that in the next question.
ANSWER CANT BE C BEC TOTAL HASNT BEEN INITILIZED SO OUTPUT WILL BE MISSING NUMERIC VALUE SIMILAR IS THE CASE OF D
@c: total initalised with missing value. Missing Value + any value is always a missing value.
@d: in every step of the data procedure, total is reinitialised as a missing value. That#s why total coincides with receipts for every observation.