MVFILL procedure

Replaces missing values in a vector with the previous non-missing value in that vector (J.T.N.M. Thissen).

No options

Parameter

VECTORS = vectors Variates, texts or factors whose missing values are replaced by the previous non-missing value of that vector

Description

A data matrix often has the values of a grouping variable in one column and values of quantitative measurements in other columns. However, one common method of data entry is to specify the value of the grouping variable only in the first row of each group. Procedure MVFILL replaces the missing values in a vector (variate, text or factor) with the previous non-missing value in that vector. If the first values of the VECTOR parameter are missing there is then no previous non-missing value, and these values remain missing.

Options: none.

Parameter: VECTORS.

Method

The procedure uses the data manipulation functions SHIFT, DIFFERENCE and NEXPAND.

Action with RESTRICT

Restrictions are ignored. This means that missing values are replaced in the same way as for unrestricted vectors. However, after the procedure the vectors are restricted in the same way as before.

See also

Directive: INTERPOLATE.

Procedures: MULTMISSING, SVHOTDECK.

Commands for: Calculations and manipulation.

Example

CAPTION   'MVFILL example'; STYLE=meta
FACTOR    date, person
READ      [LAYOUT=fixed; SKIP=*; FORMAT=!(6,5,4)]\ 
          date, person, ycount; FREPRESENTATION=levels,labels,*
960702    A   *
              7
          B  12
960701    A   8
960703    A   *
          B   *
             10
              2
960704    A   7
              4
          B   4
             11
              *
              5
     :
CAPTION   'Original data'
PRINT     date,person,ycount; DECIMALS=0
MVFILL    date,person,ycount
CAPTION   'Data after filling missing values'
PRINT     date,person,ycount; DECIMALS=0
Updated on March 7, 2019

Was this article helpful?