A SAS programmer writes: DATA output; SET input; IF _N_ = 1 THEN DO; ... END; RUN; What is the purpose of the IF _N_ = 1 condition?
Select an answer to reveal the explanation.
Short Explanation
Here's the deal — _N_ counts DATA step iterations, so IF _N_ = 1 runs the DO block only on the first iteration, when the first observation is read. You use it for setup logic that should happen once.
Full Explanation
The correct choice is the one stating that the condition executes the DO block only during the first iteration of the DATA step, when the first observation is being read. _N_ is a SAS automatic variable that counts the iteration of the DATA step loop, so it equals 1 only on the first iteration. This pattern is commonly used to initialize variables, open files, or execute setup logic exactly once. The option saying it processes only the first variable is wrong because _N_ counts iterations, not variables. The option saying it assigns 1 to _N_ for all observations is wrong because SAS automatically increments _N_. The option saying it filters output to one observation is wrong because the condition controls when the DO block executes, not which observations are output.