Creating new date variable by client ID

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

Creating new date variable by client ID

Juliana-7
I would appreciate any help with the following problem

I have data that is structured as follows:

CLIENT_ID   Year
11111     1999
11111     2000
11111     2000
11111     2001
22222     2000
22222     2002
33333     1998
33333     1998
33333     1998
33333     2000

I would like to create a new variable that includes only the earliest
year, repeated for the same subject such that the data look as
follows:

CLIENT_ID   Year   NewVar
11111     1999     1999
11111     2000     1999
11111     2000     1999
11111     2001     1999
22222     2000     2000
22222     2002     2000
33333     1998     1998
33333     1998     1998
33333     1998     1998
33333     2000     1998

Again, any help is appreciated
Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Creating new date variable by client ID

Richard Ristow
At 01:30 PM 7/31/2007, Juliana wrote:

>I have data that is structured as follows:

|-----------------------------|---------------------------|
|Output Created               |31-JUL-2007 16:44:03       |
|-----------------------------|---------------------------|
CLIENT_ID Year

   11111   1999
   11111   2000
   11111   2000
   11111   2001
   22222   2000
   22222   2002
   33333   1998
   33333   1998
   33333   1998
   33333   2000

Number of cases read:  10    Number of cases listed:  10

>I a variable that includes only the earliest year, repeated for the
>same subject such that the data look as follows:
>
>CLIENT_ID   Year   NewVar
>11111     1999     1999\
[...]
Like the above LIST, this is SPSS 15 draft output (WRR:not saved
separately):


AGGREGATE OUTFILE=* MODE=ADDVARIABLES
    /BREAK    = CLIENT_ID
    /FrstYear = MIN(Year).
LIST.

List
|-----------------------------|---------------------------|
|Output Created               |31-JUL-2007 16:44:03       |
|-----------------------------|---------------------------|
CLIENT_ID Year FrstYear

   11111   1999   1999
   11111   2000   1999
   11111   2000   1999
   11111   2001   1999
   22222   2000   2000
   22222   2002   2000
   33333   1998   1998
   33333   1998   1998
   33333   1998   1998
   33333   2000   1998


Number of cases read:  10    Number of cases listed:  10
===================
APPENDIX: Test data
===================
DATA LIST LIST SKIP=1
    /CLIENT_ID   Year
     (F5,        F4).
BEGIN DATA.
     CLIENT_ID   Year
     11111     1999
     11111     2000
     11111     2000
     11111     2001
     22222     2000
     22222     2002
     33333     1998
     33333     1998
     33333     1998
     33333     2000
END DATA.
LIST.