counting dates within cases

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

counting dates within cases

Tracy Hazelton
Hi everyone,
I have a large dataset where I have many service dates for each case and I
want to be able to assign each service date with a corresponding number so
that I can look at the first three service dates for my analysis, but I
can’t figure out how to do this.  Here is a small example of my data and
the new variable I want. From looking at past posts it seems I need to use
a LAG function, but I just don’t know how to really do this. Also the
dates I'm using are pure-no time part within the date.

Any help will be GREATLY appreciated,
Tracy

Case No.            service date       *New Variable*
1                    10/5/2007                    1
1                    10/7/2007                    2
1                    11/2/2007                    3
2                    7/1/2007                     1
2                    7/5/2007                     2
3                    12/4/2007                    1
3                    12/9/2007                    2
3                    12/13/2007                   3
3       12/22/2007                   4

=====================
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: counting dates within cases

Oliver, Richard
rank variables=servicedate by caseno /rank into newvariable.
 
where servicedate is service date, caseno is case number, and newvariable is the new variable.

________________________________

From: SPSSX(r) Discussion on behalf of Tracy Hazelton
Sent: Thu 4/17/2008 12:43 PM
To: [hidden email]
Subject: counting dates within cases



Hi everyone,
I have a large dataset where I have many service dates for each case and I
want to be able to assign each service date with a corresponding number so
that I can look at the first three service dates for my analysis, but I
canâEUR(tm)t figure out how to do this.  Here is a small example of my data and
the new variable I want. From looking at past posts it seems I need to use
a LAG function, but I just donâEUR(tm)t know how to really do this. Also the
dates I'm using are pure-no time part within the date.

Any help will be GREATLY appreciated,
Tracy

Case No.            service date       *New Variable*
1                    10/5/2007                    1
1                    10/7/2007                    2
1                    11/2/2007                    3
2                    7/1/2007                     1
2                    7/5/2007                     2
3                    12/4/2007                    1
3                    12/9/2007                    2
3                    12/13/2007                   3
3       12/22/2007                   4

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