Training Tips

[Skip Global Navigation]

Training

Training Home

SPSS Trainer Tip: SPSS®13.0 for Windows®

Instructor profile

Steve Fink

Name: Steve Fink

Home office: SPSS Arlington, VA

About Steve: Steve has worked for SPSS as an Education Consultant since December 2001. He holds a bachelor's degree from George Washington University and received his master's degree from the University of Connecticut. In Steve's spare time he enjoys racquetball, tennis, reading and spending time with his family and friends.



Extracting date information using the updated compute procedure

Extracting date information using SPSS for Windows used to require a COMPUTE statement to create the variable, followed by a conversion statement. SPSS 13.0 enables you to combine these two steps into one.

Here's how:

Figure 1 below is a dataset of two variables, both defined as date fields. The goal is to calculate the number of days between STDAY and ENDDAY.

Dataset of two date variables
Figure 1: Dataset of two date variables

From the menus, choose Transform>>Compute.

Type numdays under the Target Variable text box (you can click the type and label to complete this information).

Under the Function group, select Date Arithmetic (functions are now organized into groups).

Under Functions and Special Variables, select Datediff (see Figure 2 below).

Compute dialog box
Figure 2: Compute dialog box

Click the up arrow Up arrow to place the Datediff function into the Numeric Expression box.

Highlight the first question mark, select ENDDAY, and click the right arrow Right arrow

Highlight the second question mark, select STDAY, and click the right arrow Right arrow

Highlight the third question mark, and type 'days' (see Figure 3 below). (Scroll down the HELP MENU section to view other options.)

Compute variable dialog box
Figure 3: Compute variable dialog box with completed Datediff information

Click OK to display the dataset (see Figure 4 below).

Dataset of new variables
Figure 4: Dataset of original and new numdays* variables

* Note: Numdays is 366 for the second record due to 1992 being a leap year.

We offer SPSS courses at locations around the world.
Find a course in the location nearest to you.