BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
shellp55
Quartz | Level 8

Hello

 

I am using SAS 9.3.

 

I have inpatient and outpatient data.  I want to link the Emergency Room abstract with the inpatient one for those admitted via the ER.  However, the admit date of the inpatient visit could be a day later than the end date of the ER abstract.  Is there any way to do this?

 

The ED table only has those visits admitted and the inpatient cases only have those admitted via the ED.  The current resulting dataset is missing out on those where the ED end date is a day later i.e. the inpatient admit date is April 10, 2017 and the ED end date is April 11, 2017. 

 

My current code:

proc sql;
create table Links as select
a.HCN,
a.alias,
a.admdate,
b.regdate,
b.triage
from inpatients as a
left join ED as b
on a.HCN = b.HCN 
and b.enddate<=a.admdate<=b.enddate+1;

Any and all assistance greatly appreciated.

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Try the join condition

 

on a.HCN = b.HCN
and a.admdate between b.enddate and b.enddate+1

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

Try the join condition

 

on a.HCN = b.HCN
and a.admdate between b.enddate and b.enddate+1

PG
Reeza
Super User

Is it a date or date time variable? I thought it was usually DT. It's also really rare but it can be longer than a day. 

shellp55
Quartz | Level 8

Thanks to you both for responding.  I worked on it last night and I created a new field called "d_date" that was the +1 and added as an OR statement.  So PGStats response but instead of using "+1" I built that as a field elsewhere. 

 

Thanks so much!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3 replies
  • 990 views
  • 0 likes
  • 3 in conversation