The RETAIN statement determins the initial value for a variable The syntax of the RETAIN statement allows it to specify an ‘initial value’ — i.e. its value at the start of the very first iteration of the DATA step. So we can initialize the variable by assigning a constant value or assigning a value that comes from another variable.

The RETAIN statement retains SAS value in the PDV for the duration of an iteration or multiple iterations. But keep in mind that if the variable has already been defined prior to the RETAIN statement, then RETAIN cannot alter the type or length of the variable