Summary

Statements

RETAIN variable-1 < . . . variable-n>;
retains the value of variable for use in a subsequent observation. The RETAIN statement prevents the value of the variable from being reinitialized to missing when control returns to the top of the DATA step.
The RETAIN statement affects variables that are created in the current DATA step (for example, variables that are created with an INPUT or assignment statement). Variables that are read with a SET, MERGE, or UPDATE statement are retained automatically. Naming them in a RETAIN statement has no effect.
The RETAIN statement can assign an initial value to a variable. If a variable needs to have the same value in all observations of a DATA step, then it is more efficient to put the ...

Get Step-by-Step Programming with Base SAS 9.4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.