Deriving variables from a date variable

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

Deriving variables from a date variable

John Amora
Hi ALL,
 
The date variable is in the format "month/day/year".  From that variable, I want to create two additional variables:  "month" and "year".  Please help for the syntax.
 
Thank you in advance.
Johnny Amora
 


      Jazz up your status message with Emoticons

====================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: Deriving variables from a date variable

Mark Palmberg
I think the date/time wizard makes this pretty easy.  Check it out.

On Thu, Oct 23, 2008 at 9:55 PM, Johnny Amora <[hidden email]>wrote:

> Hi ALL,
>
> The date variable is in the format "month/day/year".  From that variable, I
> want to create two additional variables:  "month" and "year".  Please help
> for the syntax.
>
> Thank you in advance.
> Johnny Amora
>
>
>
>      Jazz up your status message with Emoticons
>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: Deriving variables from a date variable

ariel barak
In reply to this post by John Amora
Hi Johnny,

If the variable/s you have are recognized as SPSS date variable/s, you
should check out the XDATE command. I use the following syntax to get the
admission month and year out of a date variable called Admit_Date at work
all the time.

COMPUTE AdmitYear=XDATE.YEAR(Admit_Date).
COMPUTE AdmitMonth=XDATE.MONTH(Admit_Date).
EXE.

You can use the XDATE command to extract many different time metrics i.e.
i.e. day of the month, day of the year, day of the week, hour, minute,
quarter, etc.

HTH,
Ari

On Thu, Oct 23, 2008 at 9:55 PM, Johnny Amora <[hidden email]>wrote:

> Hi ALL,
>
> The date variable is in the format "month/day/year".  From that variable, I
> want to create two additional variables:  "month" and "year".  Please help
> for the syntax.
>
> Thank you in advance.
> Johnny Amora
>
>
>
>      Jazz up your status message with Emoticons
>
> 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