INTNX moves by intervals.
INTCK counts interval boundaries crossed.
If you want to adjust by months you could use INTCK with MONTH interval.
interview_age = baseline_age*12 + intck('month',baseline_date,interview_date,'cont');
Or perhaps just divide the number of days by the average number of days in a month.
interview_age = baseline_age*12 + round((interview_date-baseline_date)/(365.25/12));
I am assuming you have AGE at some baseline date instead of actual DATE OF BIRTH. Is that correct?
Looks like you are storing AGE in months since you multiply it by 12? Normally people store AGE in years. How are you storing AGE?
Do you have the INTERVIEW_AGE for each follow-up interview?
If you have the BASELINE_AGE and BASELINE_DATE then you could get pretty close the calculating an INTERVIEW_AGE by doing something like this:
Convert BASELINE_AGE and BASELINE_DATE to a date, perhaps the beginning of the month that is BASELINE_AGE years before BASELINE_DATE.
Then calculate the interview age from that date to the current interview date.
INTERVIEW_AGE = intck('year',intnx('year',baseline_date,-baseline_age),interview_date);
Hi Tom,
Thanks for your response! Yes, we only have age at Baseline, not date of birth. We are capturing age in years but then have to convert to months for our purposes, which is why they are multiplied by 12.
We do have interview age for each follow-up interview, but these are sometimes inconsistent due to human error. I have gone through and fixed it the best that I can, by basically making all ages the same across the interviews of each participant and trying to add on months from there.
I see what you are saying about turning age and date both into dates! How would you go about changing age to a date that is comparable though? The way I am thinking about it, if I convert age to a date the differences between age and interview_date as they correspond to date would not be consistent.
I am looking into the code you posted as well! Intck is new to me, but seems like it is calculating the difference in years between the two? Or do I have that wrong?
Thanks again for your help!
INTNX moves by intervals.
INTCK counts interval boundaries crossed.
If you want to adjust by months you could use INTCK with MONTH interval.
interview_age = baseline_age*12 + intck('month',baseline_date,interview_date,'cont');
Or perhaps just divide the number of days by the average number of days in a month.
interview_age = baseline_age*12 + round((interview_date-baseline_date)/(365.25/12));
That makes sense, thanks for your help!
Something like this?
*Test needed because some people take surveys 30 days after last one, since windows are 30 days apart;
if 25 <=INTERVIEW_DIF <= 45 then CORRECTION=1;
else if 45 < INTERVIEW_DIF <= 75 then CORRECTION=2;
else if 75 < INTERVIEW_DIF <= 105 then CORRECTION=3;
etc..
if CORRECTION then do;
if VRID_3MO ne "" then INTERVIEW_AGE = (AGE*12 + CORRECTION );
else if VRID_6MO ne "" then INTERVIEW_AGE = (AGE*12 + CORRECTION + 3);
else if VRID_9MO ne "" then INTERVIEW_AGE = (AGE*12 + CORRECTION + 6);
end;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.