Date: Fri, 7 Sep 2007 10:02:50 -0400
Reply-To: Gene Maguin <emaguin@buffalo.edu>
Sender: "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From: Gene Maguin <emaguin@buffalo.edu>
Subject: Re: How to recode missing values ?
In-Reply-To: <200709070307.l86M41PV004685@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
M'hammed.
The trick is to get your file sorted so that the case with valid value for
AA is the first in the list and use the lag function to pull that value of
AA across all subsequent cases with the same value of ID.
First, sort your file by ID and AA. The important thing is that you want the
result to look like this. Notice the change in the order for the ID=2 cases.
The default ascending sort order may do this. If not, switch AA to a
descending sort order while leaving ID in ascending. If you don't know how
to do this look in the syntax refererence or the help file.
ID AA BB CC DD
001 1 1 1 1
001 . . . 2
001 . . . 3
001 . . . 3
001 . . . 4
002 2 2 2 2
002 . . . 4
002 . . . 4
002 . . . 4
002 . . . 4
002 . . . 4
002 . . . 4
003 . . . 5
003 . . . 4
003 . . . 5
003 . . . 5
Then do this.
If (Id eq lag(id)) AA=lag(AA).
What are you going to do about the ID=3 cases?
WARNING:
Can this situation occur? What do you want to do then?
003 2 2 2 2
003 . . . 4
003 . . . 4
003 . . . 4
003 5 5 6 2
Gene Maguin