The RETAIN statement is one method that SAS ® programmers commonly use for making comparisons across observations. One source of misunderstanding around the RETAIN statement centers around how long a value is retained and the ability or need to reset retained variables in many circumstances. This paper clarifies, through examples, how the RETAIN statement overrides the default behavior of a DATA step and maintains a variable’s values until the value is reset. The scope of the paper is to demonstrate the use of the RETAIN statement in conjunction with assignment statements
To submit an update or takedown request for this paper, please submit an Update/Correction/Removal Request.