Retrieving parts of a number

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

Retrieving parts of a number

jimjohn
can someone plz hel[p me with this:

i have a variable in number format to represent the month and year. For example, 200610 corresponds to the 10th month of 2006. i want to create another variable that contains only the month of the year. so i want to look at the date column, and get only the last two digits. any ideas how i can dfo this in spss? thx.
Reply | Threaded
Open this post in threaded view
|

Re: Retrieving parts of a number

Maguin, Eugene
JimJohn,

I think the simplest way to do this is to use the Mod function (look it up
in the universals part of the syntax reference).

Let x be your year-month variable.

Compute y=mod(x,100).

Gene Maguin

=====================
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: Retrieving parts of a number

Oliver, Richard
In reply to this post by jimjohn
compute month=mod(date, 100).

As in:

data list free /date (f6).
begin data
200610
end data.
compute month=mod(date, 100).
list.

-----Original Message-----
From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of jimjohn
Sent: Tuesday, September 02, 2008 11:34 AM
To: [hidden email]
Subject: Retrieving parts of a number

can someone plz hel[p me with this:

i have a variable in number format to represent the month and year. For
example, 200610 corresponds to the 10th month of 2006. i want to create
another variable that contains only the month of the year. so i want to look
at the date column, and get only the last two digits. any ideas how i can
dfo this in spss? thx.
--
View this message in context: http://www.nabble.com/Retrieving-parts-of-a-number-tp19273595p19273595.html
Sent from the SPSSX Discussion mailing list archive at Nabble.com.

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