What is the primary effect of the RETAIN statement in a SAS DATA step?
Select an answer to reveal the explanation.
Short Explanation
You're right to focus on how SAS handles variables between iterations. By default, SAS resets many variables to missing at the start of each DATA step iteration, but RETAIN keeps the previous value instead. That makes it useful for running totals, flags, and lag-style calculations.
Full Explanation
The correct choice says RETAIN keeps a variable's value from the previous iteration instead of resetting it to missing at the start of each DATA step iteration. By default, SAS resets non-retained variables to missing each iteration; RETAIN carries values forward, useful for running totals, flags, and lag calculations. The macro-variable choice is wrong because RETAIN works within a DATA step, not across programs. The output-dataset choice is wrong because that describes DROP/KEEP. The SET/MERGE choice is wrong because RETAIN does not prevent overwriting.