DATA Step, Macro, Functions and more

Problem with prep question

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 5
Accepted Solution

Problem with prep question

Hi, I'm preparing for my Base Programming Exam and I'm stuck with one question from the Pass4Sure catalogue. The explanation doesn't really help:

 

Unbenannt.PNG

The right answer is A. While I do understand why A doesn't produce a missing value in the last observation, I don't get why any of the other options should. I've pondered over this one for a while now but I'm not getting further. Especially option D should effectively do the same as A in my opinion.

 

I would appreciate your help!


Accepted Solutions
Solution
‎12-15-2016 05:44 AM
Super User
Posts: 6,962

Re: Problem with prep question

options B and D use a simple totquantity + quantity calculation; they cause no automatic retain, always reference a missing value (totquantity), therefore the result will be missing.

option C is a simple syntax error.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
‎12-15-2016 05:44 AM
Super User
Posts: 6,962

Re: Problem with prep question

options B and D use a simple totquantity + quantity calculation; they cause no automatic retain, always reference a missing value (totquantity), therefore the result will be missing.

option C is a simple syntax error.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 5

Re: Problem with prep question

Now I get it, thanks a lot!

Regular Contributor
Posts: 194

Re: Problem with prep question

Answer D uses the "+" operator which produces a missing value if one of the operands is missing.
The 0 in the retain statement only provides an initialization which is overwritten by the operation.
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 165 views
  • 1 like
  • 3 in conversation