How to get the earliest date into a new variable

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

How to get the earliest date into a new variable

Jim-208
I can't figure this one out. I have a list of cases sorted by DATE. I want
to identify the earliest case by DATE and copy that single value for DATE
into a new variable I'll call EARLIESTDATE.

All cases will have the same value for EARLIESTDATE. I then plan to
calculate the difference between DATE and EARLIESTDATE for some additional
analysis.

Any help is appreciated. Thanks.

Jim

=====================
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 get the earliest date into a new variable

Maguin, Eugene
Jim,

This is a job for Aggregate. Read the documentation on that command. In 17
and on you can do this

AGGREGATE OUTFILE=* MODE=ADDVARIABLES/earliestdate=min(date).

In 16 and before you have to do this.

Compute rec=1.
Execute.
AGGREGATE OUTFILE=* MODE=ADDVARIABLES/break=rec/earliestdate=min(date).


Gene Maguin


>>I can't figure this one out. I have a list of cases sorted by DATE. I want
to identify the earliest case by DATE and copy that single value for DATE
into a new variable I'll call EARLIESTDATE.

All cases will have the same value for EARLIESTDATE. I then plan to
calculate the difference between DATE and EARLIESTDATE for some additional
analysis.

=====================
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 get the earliest date into a new variable

Jim-208
In reply to this post by Jim-208
That was exactly what I needed. It worked perfectly! Thanks!

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