Replaces NaN values based on other known data points.
NAFILL(series, method)
series 
 
A series or table.  
method 
 
An integer. Method used to "fill" NaN values:

A series or table.
W1: {2, 5, 7, 9, nan, 13, 15}
W2: nafill(W1, 1)
W3: nafill(W1, 3)
W2 replaces each NaN value with the previous known (i.e. nonnan) value. The new series is {2, 5, 7, 9, 9, 13, 15}.
W3 replaces each NaN value with the next known (i.e. nonnan) value. The new series is {2, 5, 7, 9, 13, 13, 15}.
a = {nan, 2, nan, 4, nan};
naf = nafill(a, 1);
naf0 = nafill(a, 0);
naf1 = nafill(a, 1);
naf2 = nafill(a, 2);
naf3 = nafill(a, 3);
naf4 = nafill(a, 4);
naf == {nan, 2, nan, 4, nan}
naf0 == {nan, 2, nan, 4, nan}
naf1 == {nan, 2, 2, 4, 4}
naf2 == {2, 2, 2, 4, 4}
naf3 == {2, 2, 4, 4, nan}
naf4 == {2, 2, 4, 4, 4}
Both naf and naf0 do not replace NaN values.
naf1 fills each NaN value with the previous nonnan value.
naf2 fills each NaN value with the previous nonnan value or if no nonnan value is found, the next nonnan value is used.
naf3 fills each NaN value with the next nonnan value.
naf4 fills each NaN value with the next nonnan value or if no nonnan value is found, the previous nonnan value is used.
NAFILL replaces NaN values of a series with existing non NaN values.
The method values of 1 and 0 both retain NaN values when encountered in a computation. However, 1 specifies a hardware based NaN detection algorithm where the floating point processor signals the existence of NaN values. Most internal series math computations use the hardware detection method to retain encountered NA values.
Some functions such as MOVAVG default to a method of 2 where NaN values are substituted forward with the last known value or if no value is found, substitute backwards using the next known value. For a long series with many NaN values, this can result in slower processing, but the result will generally not contain NaN values.
The DEFAULT_NA_METHOD configuration parameter in DADISP.CNF specifies the default NaN fill method.
See SETNAVALUE to replace NaN values with a set value.
See REMOVENA to delete NaN values.
READTABLE will read the strings NaN, NA or NULL as NAVALUES.