I just came across the problem that a date in Stata is not the same as a date in SPSS. They are, however, based on the same principle: time variables, e.g. a variable containing days, contain the number of elapsed time units (days, weeks, months, seconds, or other date units) since a base date which is defined by the software.
In Stata, the base date is the first time unit in 1960 (e.g. January 1, 1960). For other time units, it is the first minute, second, week, etc. in 1960. A date variable which is formatted as containing dates (measured in days) has the value 0 for January 1, 1960; +1, for January 2; -1 for December 31, 1959. The same principle applies for storing time information that contains information on (mili)seconds, minutes, weeks, etc. (see the help function is stata).
In SPSS, the principle is the same, but the base date is different. Here, it is: October 14, 1582 (start of the gregorian calendar, but probably never used in empirical analyses…).
That means, the raw time information is never useful to read because it is simply a running number. In order to display the format properly (e.g. as “January 2, 2009” instead of the Stata value for this day, which is “17899”; check –di td(02jan2009)–), one has to format the date variable with the appropriate format, e.g. with %td in the case of date formats.
Coming to my actual problem, the conversion of a variable stored as e.g. 14.03.2009 21:23 (i.e. giving information on the date and the time) in SPSS to Stata with an appropriate format:
1) Transfer the SPSS dataset to the Stata format
2) Stata does not read seconds format, but only miliseconds: multiply the original variable (here: nqdatsta) by 1000; in addition substract the difference between the two base dates:
gen helpdate = nqdatsta*1000 - (tc(01jan1960 00:00:00) - tc(14oct1582 00:00:00))
3) Format the new variable to get proper time information:
format helpdate %tc
And continue working in Stata…
Leave a Reply
You must be logged in to post a comment.