RETAIN <element-list(s) <initial-value(s) | (initial-value-1) | (initial-value-list-1) > |
Another example:
libname class 'SAS-data-library';
proc sort data=class.allscores;
by id;
run;
data class.bestscores;
drop grade;
set class.allscores;
by id;
/* Prevents HIGHEST from being reset*/
/* to missing for each iteration. */
retain highest;
/* Sets HIGHEST to missing for each */
/* different ID value. */
if first.id then highest=.;
/* Compares HIGHEST to GRADE in */
/* current iteration and resets */
/* value if GRADE is higher. */
highest=max(highest,grade);
if last.id then output;
run;