How to replace the missing values by program

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

How to replace the missing values by program

Haiyan.Gao
Dear all,

Does anyone know how to write a loop to replace the missing values by
the non missing value above in a variable? E.g. there are 5 missing
values in var1, how to replace the missing data in case 2-4 by 1, and
the missing data in case 6-7 by  0.98 in case 5 of var1.
case    t       var1
1       0.1     1
2       0.2     .
3       0.3     .
4       0.4     .
5       0.5     0.98
6       0.55    .
7       0.6     .
8       0.65    0.97
.       .    .

Any suggestion would be highly appreciated.

Best wishes,
haiyan

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: How to replace the missing values by program

Maguin, Eugene
Haiyan,

You have

case    t       var1
1       0.1     1
2       0.2     .
3       0.3     .
4       0.4     .
5       0.5     0.98
6       0.55    .
7       0.6     .
8       0.65    0.97


Use this.

If (sysmis(var1)) var1=lag(var1).


Gene Maguin

=====================
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
Reply | Threaded
Open this post in threaded view
|

Re: How to replace the missing values by program

Haiyan.Gao
In reply to this post by Haiyan.Gao
Gene,

Many thanks. It worked.

Best wishes,

Haiyan


-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of
Gene Maguin
Sent: 24 October 2007 16:29
To: [hidden email]
Subject: Re: How to replace the missing values by program


Haiyan,

You have

case    t       var1
1       0.1     1
2       0.2     .
3       0.3     .
4       0.4     .
5       0.5     0.98
6       0.55    .
7       0.6     .
8       0.65    0.97


Use this.

If (sysmis(var1)) var1=lag(var1).


Gene Maguin

=====================
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

=====================
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