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.
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".
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.
13. Click on "finish" and we get the following change in our dataset. we can see a new variable created named age
Watch this video to see the steps.
Hope you enjoyed the tutorial. Share if you like it!! See you in the next tutorial.