In both SAS and Stata, dates are numeric values that count the number of days from January 1, 1960. In SPSS, dates are numeric values that count the number of seconds from the inception of the Gregorian calendar. The Gregorian calendar was adopted on October 14, 1582. For example, in SAS or Stata, March 7, 2002 would be represented as 15406, while in SPSS it would be represented as 13,234,838,400. Dates that occurred before January 1, 1960 would be negative numbers in SAS and Stata, but would still be a large positive number in SPSS. For example, March 7, 1942 would be -6509 in SAS and Stata, and 11,341,382,400 in SPSS.

We need to do two things to convert SAS or Stata dates into SPSS dates. The first task is to find the number of days between October 14, 1582 and January 1, 1960. The second task is to convert days to seconds. To do this, it is helpful to know that there are 86,400 in a day.

We can use a few functions in SPSS to help us convert SAS or Stata dates in
SPSS dates. The **date.mdy** function returns a date value for the day,
month and year provided. The **xdate.tday** function returns the number
of days between October 14, 1582 and the date we enter (as a variable).

Let’s start by inputting a tiny sample dataset. To create the variable
**spss_date**, which will be the SPSS date version of **s_date** (dates in
the metric used by SAS and Stata), we will create the variable **diff**,
which contains the date January 1, 1960. Next we will create the variable
**diff2**, which will contain the number of days between October 14, 1582 and
January 1, 1960. (There are 137,775 days between these two dates.)
Finally, we will create the variable **spss_date** by adding 137775 to **
s_date** and then multiplying this value by 86400. Of course, creating
these intermediate variables (i.e., **diff** and **diff2**) is not
necessary, as shown when creating the variable **spss_date1**.

data list list /s_date. begin data. 17215 17845 17598. end data. compute diff = date.mdy(1,1,1960). compute diff2 = xdate.tday(diff). compute spss_date = (s_date + 137775) * 86400. formats s_date (f6.0) diff (f4.0) diff (adate10) diff2 (f8.0) spss_date (adate10). list.

s_date diff diff2 spss_date 17215 01/01/1960 137775 02/18/2007 17845 01/01/1960 137775 11/09/2008 17598 01/01/1960 137775 03/07/2008 Number of cases read: 3 Number of cases listed: 3

compute spss_date1 = (s_date+xdate.tday(date.mdy(1,1,1960)))*86400. formats spss_date1 (adate10). list s_date spss_date1.

s_date spss_date1 17215 02/18/2007 17845 11/09/2008 17598 03/07/2008 Number of cases read: 3 Number of cases listed: 3