Search code examples
spss

How to repeat a case value until a different value is encountered?


I currently have a data file that is structured like this:

   1  
   -  
   -  
   2  
   -  
   3  
   -  

I would like it to look like this:

   1  
   1  
   1  
   2  
   2  
   3  
   3  

Unfortunately I do not how to achieve this in SPSS. Is there are a simple command that could recode the data this way?


Solution

  • I have found the answer, by using the LAG function. (I defined 9999 as a missing value).

    IF (variable = 9999) variable=LAG(variable). EXECUTE.