Conflicting Ages Generated using INTCK

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Conflicting Ages Generated using INTCK

[ Edited ]

Hi All, I'm attempting to calculate age at Event (1st vaccination) for a data set I'm using. I've used this forum to find several different ways to calculate age at event, however, they all result in different values. I'm hoping to find out which of these calculations represents the true age at vaccination for this population.

 

A few details- I calculated participants age at the start of the study ( 12-1-2016), which gave me an age range of 7-21 yrs ( Agetest). I'm using version 9.4.

 

I want to exclude anyone who received a vaccination before age 9. Now, when I attempt to calculate participants' age at first vaccination ( Event), I get different values for how many are actually <9 at the event. With the coding below I get participants age at event as between 0-21. I'm assuming that some clinics erroneously listed the participant's dob and vaccination date as the same. What am I missing about this code that would explain these differences and which code reflects an accurate count at each age?

 

 

Here's the code I've used thus far;

 

data want; set have; today=MDY(12,01,2016);

days=today-BIRTH_DATE;

AGEtest= floor ((intck('month',BIRTH_DATE,today) - (day(today) < day(BIRTH_DATE))) / 12);*age at study start;

 

AgeatVacc=INTCK ('YEAR', BIRTH_DATE, CHVaccDate_1);run;

 

AgeVtest=floor ((intck('month',BIRTH_DATE,CHVaccDate_1) - (day(CHVaccDate_1) < day(BIRTH_DATE))) / 12); *age at first vacc date;

 

AgeVtest2=floor ((intck('month',BIRTH_DATE,CHVaccDate_1)) / 12);*looking at diff btw birth date and 1st vacc date- gives different answers;

 

AgeVTest5=floor ((intck('YEAR',BIRTH_DATE, CHVaccDate_1))); RUN;


Accepted Solutions
Solution
‎01-10-2018 08:38 AM
Super User
Posts: 9,880

Re: Conflicting Ages Generated using INTCK

Posted in reply to LAsasuser79

After playing around with it, I arrived at this code:

data have;
input CLIENT_ID BIRTH_DATE :mmddyy10. CHVaccDate_1 :mmddyy10.;
VAGE = INTCK('year',BIRTH_DATE,CHVaccDate_1,"Continuous");
format BIRTH_DATE CHVaccDate_1 mmddyy10.;
datalines; 
1 08212000 04062009
2 02032002 04082011
3 05101999 11222010
4 10191999 03052012
;
run;

proc freq;
table VAGE;
run;

Run this and see if it meets your expectations.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code

View solution in original post


All Replies
Super User
Posts: 23,261

Re: Conflicting Ages Generated using INTCK

Posted in reply to LAsasuser79
What about INTCK with the AGE option?
Occasional Contributor
Posts: 9

Re: Conflicting Ages Generated using INTCK

[ Edited ]

Hi Reeza, 

 

 

Do you mean something like    AgeatEvent = INTCK('year',dob,eventdate,"Age") ? This generates missing values for the data. 

 

 

Esteemed Advisor
Posts: 5,479

Re: Conflicting Ages Generated using INTCK

Posted in reply to LAsasuser79

How about going back to basics, i.e. The Manual

 

The continuous method is useful for calculating anniversaries. For example, you can calculate the number of years a couple is married by executing the following program: 

data b;
   WeddingDay='14feb2000'd;
   Today=today();
   YearsMarried=intck('YEAR', WeddingDay, today(), 'C');
   format WeddingDay Today date9.;
run;

proc print data=b;
run;

The results are WeddingDay=14FEB2000, Today=01OCT2012, and YearsMarried=12. 
PG
Occasional Contributor
Posts: 9

Re: Conflicting Ages Generated using INTCK

This solution doesn't work because each event "wedding" date is different for each participant. This method works for calculating age of participant at study start, which I have used successfully.
Super User
Posts: 23,261

Re: Conflicting Ages Generated using INTCK

Posted in reply to LAsasuser79

LAsasuser79 wrote:
This solution doesn't work because each event "wedding" date is different for each participant. This method works for calculating age of participant at study start, which I have used successfully.

 

It should work, assuming you used two variables, please explain how it "doesn't work". 

 

 

Occasional Contributor
Posts: 9

Re: Conflicting Ages Generated using INTCK

HI Reeeza, 

 

 

This code works for calculating age at study start, which is the same start date for all participants. The output gives me the age in years for each participant. 

 

data want; set have;

today=MDY(12,01,2016);

days=today-BIRTH_DATE;

AGEtest= floor ((intck('month',BIRTH_DATE,today) - (day(today) < day(BIRTH_DATE))) / 12);*age at study start;

 

However, what I am trying to calculate is participant's age at first vaccination, which differs for each participant. Therefore, I can't plug in a date rage for the interval to check against in order to count age correctly. 

Super User
Posts: 9,880

Re: Conflicting Ages Generated using INTCK

Posted in reply to LAsasuser79

LAsasuser79 wrote:
This solution doesn't work because each event "wedding" date is different for each participant. This method works for calculating age of participant at study start, which I have used successfully.

It's time to post some example data in a data step. Right now we're fishing in the dark with respect to your data and have to make up things.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 9

Re: Conflicting Ages Generated using INTCK

[ Edited ]
Posted in reply to KurtBremser

UPDATED with data lines:

 

Kurt, 

 

See below. 

I calculate age at study start (Age Test) and most importantly age at first vaccination(VAGE). The issue I'm running into is age at first vaccination as it gives me an age range of 0-18, which isn't true based on the age of my sample ( 7-21). I've attached the output for the code. 

 

 

data Inas.hpvdata1; set Inas.hpvdata1;

today=MDY(12,01,2016);

days=today-BIRTH_DATE;

AGEtest= floor ((intck('month',BIRTH_DATE,today) - (day(today) < day(BIRTH_DATE))) / 12);*age at study start;

 

VAGE= INTCK('year',BIRTH_DATE,CHVaccDate_1,"Continuous");run; proc freq; table AGEtest VAGE;run;

proc freq; table AGEtest VAGE;run; 

 

input CLIENT_ID BIRTH_DATE  ddmmyy10. CHVaccDate_1 mmddyy10.;

data lines; 

1, 08212000, 04062009

2,02232002,  04082011

3,05101999, 11222010

4,10191999, 03052012

Super User
Posts: 9,880

Re: Conflicting Ages Generated using INTCK

Posted in reply to LAsasuser79

Quote from myself:

"post some example data in a data step".

Don't expect us to type data from pictures.

And I only risked to open your Word document because I have LibreOffice at hand, which reduces the risk of malware somewhat. Many of the people here won't be able to access a docx because their firewalls block Office files.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 9

Re: Conflicting Ages Generated using INTCK

Posted in reply to KurtBremser

Noted. I've updated the post with a few data lines. 

Solution
‎01-10-2018 08:38 AM
Super User
Posts: 9,880

Re: Conflicting Ages Generated using INTCK

Posted in reply to LAsasuser79

After playing around with it, I arrived at this code:

data have;
input CLIENT_ID BIRTH_DATE :mmddyy10. CHVaccDate_1 :mmddyy10.;
VAGE = INTCK('year',BIRTH_DATE,CHVaccDate_1,"Continuous");
format BIRTH_DATE CHVaccDate_1 mmddyy10.;
datalines; 
1 08212000 04062009
2 02032002 04082011
3 05101999 11222010
4 10191999 03052012
;
run;

proc freq;
table VAGE;
run;

Run this and see if it meets your expectations.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 9

Re: Conflicting Ages Generated using INTCK

Posted in reply to KurtBremser

I did try this code earlier. My question was related to which of the INTCK code options will give the most accurate age, since they all slightly differed. I am going to use this option with the continuous option as the most valid response. 

Super User
Posts: 9,880

Re: Conflicting Ages Generated using INTCK

Posted in reply to LAsasuser79

What are you trying to calculate here:

AGEtest= floor ((intck('month',BIRTH_DATE,today) - (day(today) < day(BIRTH_DATE))) / 12);*age at study start;

There is no variable today in your whole process, so it only yields missing values.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Occasional Contributor
Posts: 9

Re: Conflicting Ages Generated using INTCK

Posted in reply to KurtBremser

Here I'm calculating the age of my sample at the start of the study. This code works to do that. I believe my value for today was included in the code I pasted. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 21 replies
  • 201 views
  • 11 likes
  • 6 in conversation