SAS : Filling missing values with the previous value

This post presents a SAS code for filling missing values with the previous value. We encounter this case when data frequencies are different such as market rate versus policy rate. The former is daily but the latter is more than monthly.


SAS : Filling missing values with the previous value



Our purpose is simple. We try to fill missing values (.) with previous values with or without grouping like the following figure.

SAS : Filling missing values with the previous values

SAS code


The following SAS code fill missing values of coupon and rate fields with their previous values. In this example, as key columns are date and accno, a sorting is necessary. If the number of key column is one, there is no need to sort.

SAS : Filling missing values with the previous values

Period.

No comments:

Post a Comment