Statalist,
I would like to generate a count variable of the number of inpatient admissions per month for each member in a health plan .
I have a panel dataset in the form of medical claims where an individual member may have more than 1 claim per month. I have a variable which indicates whether a claim was inpatient or outpatient (ip_op_cd) and I have the start (from_date2) and end date (to_date2) of that claim. The problem is that a person with one admission to the hospital in that month may have multiple claims during that hospital stay (as indicated by overlapping start and end dates). May I get some help in creating this count variable? I think(?) this would involve identifying each inpatient claim, compare the start date to the end date of any other inpatient claims that month and if it overlaps, ignore it. If it does not overlap generate an indicator variable (which is nice to have). Then do so for each member each month and then count over the indicator variables by each member each month. Claims in which the start date is in one month and the end date is in another month should only be counted as an admission in the earlier month. Months are defined by the from date and are centered on July 2010.
The data might look like the following:
Thanks!
I would like to generate a count variable of the number of inpatient admissions per month for each member in a health plan .
I have a panel dataset in the form of medical claims where an individual member may have more than 1 claim per month. I have a variable which indicates whether a claim was inpatient or outpatient (ip_op_cd) and I have the start (from_date2) and end date (to_date2) of that claim. The problem is that a person with one admission to the hospital in that month may have multiple claims during that hospital stay (as indicated by overlapping start and end dates). May I get some help in creating this count variable? I think(?) this would involve identifying each inpatient claim, compare the start date to the end date of any other inpatient claims that month and if it overlaps, ignore it. If it does not overlap generate an indicator variable (which is nice to have). Then do so for each member each month and then count over the indicator variables by each member each month. Claims in which the start date is in one month and the end date is in another month should only be counted as an admission in the earlier month. Months are defined by the from date and are centered on July 2010.
The data might look like the following:
mbr_ckey | cmonth | ip_op_cd | from_date2 | to_date2 | indicator_admit | ct_admits |
1 | 0 | OP | July 1st 2010 | July 1st 2010 | 0 | 1 |
1 | 0 | OP | July 3rd 2010 | July 3rd 2010 | 0 | 1 |
1 | 0 | IP | July 15th 2010 | July 25th 2010 | 1 | 1 |
2 | 0 | IP | July 1st 2010 | July 5th 2010 | 1 | 2 |
2 | 0 | IP | July 3rd 2010 | July 13th 2010 | 0 | 2 |
2 | 0 | IP | July 29th 2010 | Aug 2nd 2010 | 1 | 2 |
2 | 1 | IP | Aug 15th 2010 | Aug 15th 2010 | 1 | 1 |
Thanks!
Comment