Generate Month and Year

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

Generate Month and Year

Hans Chen
Dear Sir or Madam:
Customer     Date                 Invoice
    1         07-MAY-2004         001
               ...
    2         07-MAY-2006         315
           ...
    3         07-MAY-2007         798
           ...
    4        07-MAY-2000        1010
           ...
    5        07-MAY-2001
          ...
    6        07-MAY-2002
          ...
    7     07-MAY-2003

Could you tell me how I can generate the other two Column "Month" and "Year"
on the base of "Date" in SPSS(Systax). Thanks for your help!






--
Hans Chen
Reply | Threaded
Open this post in threaded view
|

Re: Generate Month and Year

Richard Ristow
At 01:18 AM 11/25/2006, SPSS Chen wrote:

>Could you tell me how I can generate the other two Column "Month" and
>"Year"
>on the base of "Date" in SPSS(Systax). Thanks for your help!

If "Date" is an SPSS date variable (see Universals in the Command
Syntax Reference), the year as a four-digit number is

XDATE.YEAR(Date)

The month, as a number from 1 to 12, is

XDATE.MONTH(Date)

You can use these expressions in COMPUTE statements to put these values
in new variables ("columns").