Taking missing data from prior years

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Taking missing data from prior years

Jake Gross

SPSS Folks,

 

I am looking for some help coming with a concise solution to a coding problem. I have panel data in the following format representing terms enrolled. For missing years I want to fill in the last, most recent value for the time-varying variables. I have come up with a brute solution using DO IF statements, but am looking for something a little more precise and elegant.

 

ID

Term

VAR2

VAR3

VAR4

8675315

1

1

1.5

25

8675315

2

1

1.75

25

8675315

3

1

1.25

25

8675315

4

.

.

.

8675315

5

.

.

.

8675315

6

1

2

25

8675315

7

1

2.64

25

8675315

8

1

2.87

25

8675315

9

1

3.44

.

8675315

10

1

.

25

8675315

11

1

3.5

25

8675315

12

1

3.53

25

 

 

------------------------------

Jacob PK Gross

Associate Director for Research--Project on Academic Success

Indiana University

1900 E 10TH ST, SUITE 630

Bloomington IN, 47406

812-855-1604

812-855-0707 (Fax)

 

Reply | Threaded
Open this post in threaded view
|

Re: Taking missing data from prior years

Maguin, Eugene
Jacob,

I don't know if this is simpler than what you did but here is my suggestion.
Also, I don't know if I interpreted your terminology correctly, particularly
the phrase '...last, most recent value'. I assumed var2 thru var4 are time
varying. Perhaps they are not.

Do repeat x=var2 to var4.
+  do if (id eq lag(id)).
+     if (sysmis(x)) x=lag(x).
+  end if.
End repeat.


Gene Maguin

>I am looking for some help coming with a concise solution to a coding
problem. I have panel data in the following format representing terms
enrolled. For missing years I want to fill in the last, most recent value
for the time-varying variables. I have come up with a brute solution using
DO IF statements, but am looking for something a little more precise and
elegant.


ID      Term    VAR2    VAR3    VAR4
8675315 1       1       1.5     25
8675315 2       1       1.75    25
8675315 3       1       1.25    25
8675315 4       .       .       .
8675315 5       .       .       .
8675315 6       1       2       25
8675315 7       1       2.64    25
8675315 8       1       2.87    25
8675315 9       1       3.44    .
8675315 10      1       .       25
8675315 11      1       3.5     25
8675315 12      1       3.53    25

=====================
To manage your subscription to SPSSX-L, send a message to
[hidden email] (not to SPSSX-L), with no body text except the
command. To leave the list, send the command
SIGNOFF SPSSX-L
For a list of commands to manage subscriptions, send the command
INFO REFCARD