Skip to main content

Creating date variable and calculating between two dates in SPSS


Introduction
Suppose you want to enter data on "Date of birth" of participants. After that, you want to calculate the age of the participants in whatever format you like (in years, or months or days). In that case, you have to create the variable in date format and enter the data. Then, you have to subtract the date of birth from the date of survey (or you can use system date if date of survey is not available). It is known as calculating between two dates. 

How to create date variable and enter data in date format
1. Go to variable view and create a variable to represent date of birth. Give desired variable name and label.
2. After that, choose one of the date formats as shown in the given picture
.
Here, I have chosen mm/dd/yyyy format

4. Then, we have to enter the data for date of birth in "mm/dd/yyyy" format.

5. We can create another variable named "surveydate" meaning date of survey.

Now the following steps tell us how to calculate between two dates.
6. Go to "Transform" menu and click on "Date and Time Wizard".
7. After that the following dialog box appears.
8. Select "Calculate with dates and times" and click next. The following dialog box appears.
9. Select 'calculate the number of time units between two dates" and click next. After that the following dialog box appears.

10. The list of variables shows current date, date of birth and date of survey. We have to move the date of survey to "Date 1" field and date of birth to "minus date 2" field.

11.We can choose the desired unit such as years, months or days or so on. Similarly, we have to select "Truncate to integer" which removes the decimal point. We don't usually do round to integer because age is usually recorded as "completed age" but not "rounded age". Difference between Truncate and Round is that Truncate converts 22.9 into 22 but round converts 22.9 into 23. Choosing between truncating and rounding also depends on our research objectives.
12. After we choose the desired options, click on next and we get the following dialog box in which we have to write the variable name and label for new variable which is the age.

13. Click on "finish" and we get the following change in our dataset. we can see a new variable created named age
14. Similarly, we can also see the set of data created for age in years.

15. Now we can do any sort of desired analysis with this age. Note that we can calculate the age in any units from years to seconds with the help of two dates. This depends on our research purpose.

Watch this video to see the steps.


Hope you enjoyed the tutorial. Share if you like it!! See you in the next tutorial. 

Comments

  1. Great article! I agree on nearly every aspect of this information you have written. t's really full of useful and interesting facts that anybody can grasp. You have great insight on this topic. Thank you for making this so clear and understandable. date calculator

    ReplyDelete
  2. Thanks for every other informative site. The place else may just I get that kind of information written in such an ideal means? I have a venture that I’m just now operating on, and I have been on the look out for such information. note frequency

    ReplyDelete

Post a Comment

Popular posts from this blog

Median test between 2 or more independent groups in SPSS

Multiple response analysis using SPSS