27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

258 COMPUTE<br />

• V2 is a pseudo-random number from a distribution with a mean of 0 and a standard deviation<br />

of the specified value of 1.5.<br />

• You can change the seed value of the pseudo-random-number generator with the SEED<br />

specification on SET.<br />

Date and Time Aggregation Functions<br />

COMPUTE OCTDAY=DATE.YRDAY(1688,301).<br />

COMPUTE QUART=DATE.QYR(QTR,YEAR).<br />

COMPUTE WEEK=DATE.WKYR(WK,YEAR).<br />

• OCTDAY is the 301st day of the year 1688. With a DATE format, OCTDAY displays as<br />

27-OCT-1688.<br />

• QUART reads values for the quarter from the variable QTR and values for the year from<br />

the variable YEAR. If QTR is 3 and YEAR is 88, QUART with a QDATE format displays as<br />

3 Q 88.<br />

• WEEK takes the value for the week from the variable WK and the value for the year from<br />

the variable YEAR. If WK is 48 and YEAR is 57, WEEK with a DATE format displays as<br />

26-NOV-57.<br />

Date and Time Conversion Functions<br />

COMPUTE NMINS=CTIME.MINUTES(TIME.HMS(HR,MIN,SEC)).<br />

COMPUTE AGER=(YRMODA(1992,10,01)-<br />

YRMODA(YRBIRTH,MOBIRTH,DABIRTH))/365.25.<br />

• The CTIME.MINUTES function converts a time interval to number of minutes. If HR equals<br />

12, MIN equals 30, and SEC equals 30, the TIME.HMS function returns an interval of<br />

45,030, which CTIME.MINUTES converts to minutes. NMINS equals 750.50.<br />

• The YRMODA function converts the current date (in this example, October 1, 1992) and<br />

birthdate to a number of days. The birthdate is subtracted from the current date and the<br />

remainder is divided by the number of days in a year to yield the age in years.<br />

Date and Time Extraction Functions<br />

COMPUTE MONTHNUM=XDATE.MONTH(BIRTHDAY).<br />

COMPUTE DAYNUM=XDATE.JDAY(BIRTHDAY).<br />

• The XDATE.MONTH function reads a date and returns the month number expressed as an<br />

integer from 1 to 12. If BIRTHDAY is formatted as DATETIME20 and contains the value<br />

05-DEC-1954 5:30:15, MONTHNUM equals 12.<br />

• The XDATE.JDAY function returns the day of the year, expressed as an integer between 1<br />

and 366. For the value BIRTHDAY used by the first COMPUTE, DAYNUM equals 339.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!