From the course: SAS® 9.4 Cert Prep: Part 09 Summarizing Data

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Retaining values in the PDV

Retaining values in the PDV

- [Instructor] Year to Date Rain is a computed column and by default all computed columns are reset to missing when the PDV is reinitialized. In order to create an accumulating column you must override the default behavior of the PDV. First, you need the initial value of Year to Date Rain to equal zero rather than missing. Second, when the PDV is reinitialized at the beginning of each iteration of the DATA step you need SAS to retain the value of Year to Date Rain in the PDV rather than set it to missing. The retain statement is the solution. Retain is a compile-time statement that sets a rule for one or more columns to keep their value each time the PDV is reinitialized rather than being set to missing. It also provides the option of establishing an initial value in the PDV before the first iteration of the DATA step. By adding a retain statement to your program you can change the default behavior of the PDV in this…

Contents