I'm currently having a long data set with the following structure:
case | month | birthyear |
1 | 1 | 1951 |
1 | 2 | 1951 |
1 | ... | 1951 |
1 | 624 | 1951 |
2 | 1 | 1960 |
2 | 2 | 1960 |
2 | ... | 1960 |
2 | 624 | 1960 |
Then the month counts from 1 to 624 for each individual. The month "1" for each individual is the December of the year, in which they turned 15. Meaning for case 1 month 1 would be December 1966.
I now want to create a new variable "calendar date" for each individual and each month that contains the actual month and year the "month" variable is referring to. Meaning the first "calendar date" for case 1 in month 1 should be 12/1966.
Could you please advise me in how to do this with a loop/condition or whatever is needed for all individuals?
Thank you very much!
Best regards
Marie
0 Response to How to create a date variable based on the birth year and a month counting variable?
Post a Comment