BookmarkSubscribeRSS Feed
cdubs
Quartz | Level 8

Have this dataset

 

patient_id / claim_date / index_date / enroll_start / enroll_end

1 01JAN2010 01JAN2013 01JAN2010 15DEC2016

1 05FEB2012 01JAN2013 01JAN2010 15DEC2016

1 01JAN2013 01JAN2013 01JAN2010 15DEC2016

1 05AUG2015 01JAN2013 01JAN2010 15DEC2016

2 01JAN2010 03MAR2016 01JAN2010 31DEC2016

2 05FEB2012 03MAR2016 01JAN2010 31DEC2016

2 01JAN2013 03MAR2016 01JAN2010 31DEC2016

2 05AUG2015 03MAR2016 01JAN2010 31DEC2016

2 03MAR2016 03MAR2016 01JAN2010 31DEC2016

 

Want the following output (outputs mean hospitalizations per year for time period before vs. ON or after index date) 

 

patient_id avg_hosp_preindex avg_hosp_postindex

1 0.66 0.51

2 0.65 1.197

 

^ there may be manual calculation errors but basically 

avg_hosp_preindex = # of hospitalizations per year (time period from enroll_start to index_date) 

avg_hosp_postindex = # of hospitalizations per year (time period from index_date to enroll_end). 

 

I was thinking of the following steps

1. Create variable "pre index time" as enroll_start to index_date, in years

2. Create variable "post index time" as index_date to enroll_end, in years

3. Create variable "pre index hosp count" as sum of claims if claim date < index date

4. Create variable "post index hosp count" as sum of claims if claim date >= index date

5. Create variable "pre index avg hosp" as "pre index hosp count" / "pre index time" 

6. Create variable "post index avg hosp" as "post index hosp count" / "post index time" 

 

Is there a simpler way to do this? What is the best way to sum the number of claims (e.g. "pre index hosp count") by the same patient id? 

 

Thank you! 

 

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

Is index_date always the same across IDs?

cdubs
Quartz | Level 8
Yes, as well as enroll start and end

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
  • 2 replies
  • 734 views
  • 0 likes
  • 2 in conversation