replace missing value

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

replace missing value

Clive Downs
Hi Yawen,

If your data is in long format I think the following should work:

********************** syntax as follows:

* SECTION 1 define test data.
*---------------------------------.
DATA LIST FREE/  id(A3)  sales year.
BEGIN DATA
001  250  2000
001  275  2004
002  275  2000
002  320  2004
003  .      2000
003  100  2004
004 .       2000
004  200  2004
END DATA.

* SECTION 2 change format of year variable so no decimal points.
*-----------------------------------.
FORMATS year (F8.0).
EXECUTE.


* SECTION 3 restructure data.
*----------------------------------.
SORT CASES BY id year .
CASESTOVARS
 /ID = id
 /INDEX = year
 /GROUPBY = VARIABLE .

* SECTION 4 work out missing data .
*------------------------------.

IF SYSMIS(sales.2000) sales.2000 = (sales.2004 * .90).
EXE.


*************

Hope that works for you,

Regards


Clive

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

Hi, Clive,

Thanks. My data is in long format. something like this:

DATA LIST FREE/  id(A3)  Var year
BEGIN DATA

001  250  2000
001  275  2004
002  275  2000
002  320  2004
003  .      2000
003  100  2004
004 .       2000
004  200  2004
END DATA.

How the syntax should be written then?

Yawen

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