
You can do this in Analysis. My example is for the new EpiData Analysis. Similar commands work in classic analysis.
First create your time difference variable new v mois i; // integer variable called MOIS
Then sort the data by subject ID and delivery date sort sujetid accouchment;
Then calculate the time difference between records, but only when the subject ID is the same as in the previous record
mois := iif(sujetid = sujetid[_n - 1], (accouchment - accouchment[_n - 1]) DIV 30, 0);
Dividing the delivery dates by 30 gives approximate months. Dividing by 30.417 and rounding off is more accurate, but I’d go with the integers.
Jamie
SAY: you have women all identified by a personal number
When you chose a number, you have all the babies she had over time e.g. a woman had her first child in 2007, the second one in 2009, the third in 2014 and the last one in 2020
If I want to calculate the intervals between pregnancies (and compare with a risk, preeclampsia for example)
- What variable should I create?
- What command should I do to find: in 2009 the interval with the preceding pregnancy was 21 months, in 2014 the interval with the preceding was 51 months etc....
THANK YOU IF CAN HELP Best
Dr Pierre-Yves Robillard Réanimation néonatale et pediatrique, néonatologie Centre Hospitalier Régional