SPSS Tips & Tricks #18 – merge date and time

 In Tips & Tricks

Date and time can be tricky to handle, and I got this question from a user: “How do you merge a date variable with a separate time variable, so you then can calculate number of hours between to time variables?”

Here is the data file. The user want to calculate the difference between the Date2 and the other date with time. But first you have to merge the 2 right variables: “Date” with “Clock”.

Choose this command from the “Transform”-menu:

and then a “Wizard” will start (wizard = step by step dialogs).

From the first step you choose following, and then click on “Next”:

and then continue with following choice, and then click on “Next”:

and then choose the following, and after all choices (check carefully) –  click on “Next”

and write a name for the new time variable, here I call it “Date1”, then click “Finish”.

Then you should go into the “Variable View” (from the data window) to change the type, so you get a correct “Date-format”:

and I choose this format below:

Explanation: dd:day, mmm:month, yyyy: year, hh: hour, mm: minute, ss: seconds

Here is the result of the new variable “Date1”:

So now you have merged the 2 variables into a new time variable that can be used in calculations, that I will show next Monday. /Gunilla




error: Content is protected !!