I have generated person-time at risk for my population.
The %lexis macro has given me the person-years at risk for each of the age categories.
(not going to post the whole macro here. it is available below:
Author: Bendix Carstensen, 1999-2002
Update: Paul Dickman, BxC, November 2003
Bug-fix: BxC, December 2007:
If the origin= argument had missing values erroneous output would
be generated (too much risk time). Now remedied so that
observations with missing values of origin are excluded.
This macro is in: http://www.biostat.ku.dk/~bxc/Lexis/Lexis.sas
Example program: http://www.biostat.ku.dk/~bxc/Lexis/xLexis.sas
data lexis_out2;
ENTERED | EXITED | AGE_BAND | AGE_ENTRY_OLD | RISK |
15-Sep-76 | 16-Aug-80 | 35-40 | 36.08196721 | 3.917864 |
16-Aug-80 | 16-Aug-85 | 40-45 | 40 | 5 |
16-Aug-85 | 16-Aug-90 | 45-50 | 44.99896699 | 5 |
16-Aug-90 | 22-Dec-92 | 50-55 | 49.99896699 | 2.350445 |
However, I want the person-years at risk for each year the individual is in the study. For this individual, it is 1976-1992.
Here is an example of the desired output:
YEAR | AGE_BAND | RISK |
1976 | 35-40 | 0.4 |
1977 | 35-40 | 1 |
1978 | 35-40 | 1 |
1979 | 35-40 | 1 |
1980 | 35-40 | 0.67 |
1980 | 40-45 | 0.33 |
1981 | 40-45 | 1 |
1982 | 40-45 | 1 |
1983 | 40-45 | 1 |
1984 | 40-45 | 1 |
1985 | 40-45 | 0.67 |
1985 | 45-50 | 0.23 |
1986 | 45-50 | 1 |
1987 | 45-50 | 1 |
1988 | 45-50 | 1 |
1989 | 45-50 | 1 |
1990 | 45-50 | 0.67 |
1990 | 50-55 | 0.23 |
1991 | 50-55 | 1 |
1992 | 50-55 | 0.98 |
Below is additional coding for the %lexis macro -
/*the LEXIS macro written by Bendix Carstensen for splitting person-time*/
%Lexis(
data=trypt,
out=work.lexis_out,
entry=entered,
exit=exited,
fail=status,
origin=born,
left=age_from,
right=age_to,
scale=365.25,
breaks=%str(17,20,25,30,35,40,45,50,55,60,65,70,75,80,85,9999)
);
data lexis_out2;
attrib
id label="ID"
born label="Born" format=date7.
entered label="Entered" format=date7.
exited label="Exited" format=date7.
age_band label="Age-at-risk band" format=$5.
age_entry label="Age-at-entry"
age_exit label="Age-at-exit"
time_entry label="Time at entry"
time_exit label="Time at exit"
fu_yrs label="Follow-up length (years)"
status label="Death";*/;
set lexis_out;
rename age_entry=age_entry_old risk=fu_yrs;
drop age_exit fu_years lrisk;
time_entry = yrdif(born,entered,'act/act') - age_entry_old;
time_exit = time_entry + fu_yrs;
age_entry = yrdif(born,entered,'act/act');
age_exit = yrdif(born,exited,'act/act');
age_band = put(age_from, 2.0)||'-'||put(age_to-0.1, 2.0);
drop age_entry_old age_from age_to;
run;