Which keyword is used to retain the values of variables across iterations in a DATA step?

Boost your career with the SAS Base Exam Certification. Dive into multiple choice questions, detailed explanations, and flashcards to enhance your understanding and ace your exam!

The keyword used to retain the values of variables across iterations in a DATA step is "RETAIN." When you use the RETAIN statement, it prevents the SAS system from resetting the variable to missing at the beginning of each iteration of the DATA step. This means that the last value of the variable will be carried forward into the next iteration, allowing for cumulative calculations or maintaining state throughout the processing of the dataset.

This capability is particularly useful in scenarios such as calculating running totals or when you need to preserve a value for further processing in subsequent rows. The RETAIN statement essentially changes how SAS handles variable initialization and is fundamental for operations that require knowledge of prior rows’ values.

The other options do not serve this function. "KEEP" is used to specify which variables to include in the output dataset but does not affect how values are retained across iterations. "RETENTION" and "LAST" do not exist as keywords in the context of a DATA step in SAS and therefore do not apply to retaining variable values. Thus, the use of "RETAIN" is the correct approach in this context.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy