I have a cohort of 100,000+ subjects with ID, DOB, DiagnosisDate, DeathDate and I am trying to tally up person time by age intervals using the DiagnosisDate as the start date. The purpose is to compare to other summary population data on mortality (e.g. CDC NCHS). So, I am trying to create a table like the image included below. I am having trouble using SAS (EG version 7.15) arrays and macros that I think are the best way to create such a table. Here's the code I am using: DATA work.test;
SET (working dataset)
ARRAY ptage ptage020-ptage125; *Creates person time variables for each age of interest;
x = yrdif(DOB,DiagnosisDate,'act/act');
age_start = int(x);
y = yrdif(DOB,DeathDate,'act/act');
age_end = int(y);
DO i = age_start to age_end;
IF age_start = i THEN ptage(i) = i+1-x;
IF age_start LT i LT age_end THEN ptage(i)=1;
IF age_start = age_end THEN ptage(i) = y-x;
IF age_start NE age_end AND age_end = i THEN ptage(i) = 1-(ceil(y)-y);
END;
RUN; I am mostly getting an "array subscript out of range" error. This is occurring on an observation with the age_start and age_end both of 108, so I'm not sure if it is due to the way the array is referenced (variable names ending in numbers that span from 20 to 125) or from the way it is handing observations where age-start = age_end. My plan is to use the array variables (ptage20-125, PT signifies person time) and PROC SUMMARY to add up the person time in the cohort for each age. If there is an easier way... please share. Many thanks -- Aaron
... View more