I have a data set where there are up to 5 events and each event has several instruments. Therefore I have several rows for each record. Something like this:
Let's say I want to calculate the age of participant 1 at the time of the date of instrument 2 recorded during event 3. During event 1 and on the first instrument there was a question asking about date of birth. So the birthday was recorded in event 1, instrument 1, and question 2. Now I want to calculate how old record 1 was at event 3.
I want a new variable as follows:
days of life = date instrument 2 (event 3) - date question2 instrument 1 (event 1)
When I try, the new variable has no values because the 2 dates are in different rows.
RECORD | EVENT | Date instrument 1 | Question instrument 1 | Question2 instrument 1 | Question instrument 1 | Date instrument 2 | Question instrument 2 | Question instrument 2 | Question instrument 2 | Question instrument 2 |
1 | 1 | yyy/mm/dd | yyy/mm/dd | |||||||
1 | 2 | |||||||||
1 | 3 | - | - | - | - | yyy/mm/dd | ||||
2 | 1 | |||||||||
2 | 2 |
I want a new variable as follows:
days of life = date instrument 2 (event 3) - date question2 instrument 1 (event 1)
When I try, the new variable has no values because the 2 dates are in different rows.
Comment