nullspssspss-modeler

SPSS Modeler 17 : Get the next not null value


I am currently using the filler node in SPSS Modeler 17 to deal with my null values. I want to replace blank values by incrementing or decrementing values between two not null values.

For example, if I have the following values : 12 $null$ $null$ 15

I would like to replace it with : 12 13 14 15

In order to do this, I need to be able to know the last not null value and the next not null value at the same time. I am able to know the last not blank value but I have read that there is no equivalent function (like @SINCE) to know the next not null value.

Does anyone know how to get the next not null value ?

Thank you very much in advance for your help !!


Solution

  • You can create supplementary numeric ID (1,2,3..N) by Derive node set to "Derive as Count" + "Increment when: true".

    Sort it backwards thanks new ID. Derive new variable "@OFFSET(desired_field,@SINCE(desired_field/=undef))" or "@LAST_NON_BLANK(desired_field)" (if you have set null as blank in Type node upstream).

    Sort it forwards and use filler in similar fashion like you did with use of new variable.

    It is intentional that you cant look into future rows, because Modeler reads rows one after another, with exception of explicitly set number records, e.g. @OFFSET(field,-1)