17 June 2018

Last-observation-carried-forward is no longer a preferred method of imputation. It is considered quite crude and susceptible to bias, especially in e.g. Alzheimer's disease (EMA points to consider on missing data), and more sophisticated methods are favoured such as multiple imputation and mixed modelling when there are repeated measures over time. However, the code once used routinely to carry the last observation forward may be useful in analogous situations. Barbalau has described different ways of coding LOCF [ref]. I prefer to use the retain statement as follows:

Incidentally, the retain statement can also be used to order variables in a dataset, but care must be taken (see SAS help).