How to convert years into relative years in spss?

t.wang21@yahoo.com.au

Member
I sort my data according to ID in ascending order and then according to year in descending order. firm years with the same ID belong to the same firm. Imagine a firm has got 5 year observations, 2009, 2007, 2006, 2005, 2004. I would like to transform them into a new variable called relative years: 0, -2, -3, -4, -5.

I know how to do this in excel. But it took me considerable time even in a very small test sample. I was wondering whether this is achievable in SPSS. Thanks very much!
Tim

t.wang21@yahoo.com.au

Member
sorry I forgot to attach a small sample of mydata

GretaGarbo

Human

Code:
COMPUTE  year_new = year_old - 2009 .
EXECUTE.

t.wang21@yahoo.com.au

Member
Thanks! It makes sense but will work for a firm whose last available year is 2009. I have got other firms whose last available year could be any year between 2002 and 2011.
Tim

Karabiner

TS Contributor
Use AGGREGATE with firm as breaking variable, and
thereby create a new variable containing a firm's lowest
value for "year". Use this variable to compute relative year.

Or, after sorting by firm and year (descending order),
use the LAG function.

With kind regards

K.