BookmarkSubscribeRSS Feed
AaronTram
Calcite | Level 5

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

 

 

 

 

Picture1.jpg

 

1 REPLY 1
ChrisNZ
Tourmaline | Level 20

Do you realise that the way you built your array,  PTAGE[21]  is  PTAGE040  ?

Is that what you want?

 

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
  • 1 reply
  • 581 views
  • 0 likes
  • 2 in conversation