BookmarkSubscribeRSS Feed
kbinan
Fluorite | Level 6

I'm not even sure how to ask this question exactly! I have two datasets of claims data , one for Inpatient Hospital Stays with a unique identifier Event ID, Admit Date and Discharge Dates. The 2nd dataset is all the claim detail. I'm trying to group the claim detail into the Unique Identifier - simple enough with a join on a Member ID and date ranges (below). Which I originally did, however, I have discovered scenarios where Member could have back-to-back IP stays with the Discharge Date of the 1st stay equal to the Admit Date of the 2nd - stopping and starting on the same day (transferred hospitals) and a single claim that has a data of service that same day so it currently "joins" to BOTH IP stays - and I only want it to join to the first. Is there a way to even do that?

Thank you in advance for any advice!

 

FROM WORK.CLM_DATA2 A

INNER JOIN WORK.CONF_DATA_FINAL_&QTR. CF 
 		ON A.MBR_SYS_ID = CF.MBR_SYS_ID
	   AND (A.FST_SRVC_DT ge CF.ADMIT_DT	
	    and A.FST_SRVC_DT LE CF.DISCHG_DT)
1 REPLY 1
s_lassen
Meteorite | Level 14

One way is to use GROUP BY and HAVING, something like

FROM WORK.CLM_DATA2 A

INNER JOIN WORK.CONF_DATA_FINAL_&QTR. CF 
 		ON A.MBR_SYS_ID = CF.MBR_SYS_ID
	   AND (A.FST_SRVC_DT ge CF.ADMIT_DT	
	    and A.FST_SRVC_DT LE CF.DISCHG_DT)
group by A.MBR_SYS_ID
having CF.ADMIT_DT = min(CF.ADMIT_DT)

You may want to add more CF variables to the GROUP BY clause, so that you get all the different claims.

 

It is not possible to give more specific advice, when there is no example of the data (post as a data step) and no SELECT clause shown.

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