BookmarkSubscribeRSS Feed
redandwhitesox
Calcite | Level 5
 
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;
ENTEREDEXITEDAGE_BANDAGE_ENTRY_OLDRISK
15-Sep-7616-Aug-8035-4036.081967213.917864
16-Aug-8016-Aug-8540-45405
16-Aug-8516-Aug-9045-5044.998966995
16-Aug-9022-Dec-9250-5549.998966992.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:
YEARAGE_BANDRISK
197635-400.4
197735-401
197835-401
197935-401
198035-400.67
198040-450.33
198140-451
198240-451
198340-451
198440-451
198540-450.67
198545-500.23
198645-501
198745-501
198845-501
198945-501
199045-500.67
199050-550.23
199150-551
199250-550.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;

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 0 replies
  • 846 views
  • 0 likes
  • 1 in conversation