BookmarkSubscribeRSS Feed
Ranjeeta
Pyrite | Level 9

Hello,

 

I have 2 tables 

Reg_SHSC_sorted with 207 cases

CIHI_SHSC_sorted with 115 cases

I am trying to find the cases that are  present in the 1st table i.e. Reg_SHSC_sorted and missing from  the 2nd table i.e. CIHI_SHSC_sorted 

Is the following code correct?

proc sql;

create table MissingCIHI as

select a.RegID, a.days_to_removal_date,a.site,b.*

from reg_SHSC_sorted a

left join CIHI_SHSC_sorted b

on a.Reg_ID =b.ID

and a.site=b.site

and a.days_to_removal_date>=b.days_to_admdate-2

and a.days_to_removal_date <=b.days_to_ddate+2

where a.RegID NE b.ID

;quit;

5 REPLIES 5
PaigeMiller
Diamond | Level 26

@Ranjeeta wrote:

Hello,

 

I have 2 tables 

Reg_SHSC_sorted with 207 cases

CIHI_SHSC_sorted with 115 cases

I am trying to find the cases that are  present in the 1st table i.e. Reg_SHSC_sorted and missing from  the 2nd table i.e. CIHI_SHSC_sorted 

 


"Cases" meaning some ID value matches in both data sets, or "cases" meaning the entire record matches in both data sets? What do the dates in the code have to do with this problem, this is not explained anywhere.

--
Paige Miller
Ranjeeta
Pyrite | Level 9

I am interested in the Cases that have the same ID value and the days to removal date and the other dates mentioned are some of the join conditions that I want to be satisfied for cases that have the same ID value in both datasets

 

Thankyou 

PaigeMiller
Diamond | Level 26

@Ranjeeta wrote:

I am interested in the Cases that have the same ID value and the days to removal date and the other dates mentioned are some of the join conditions that I want to be satisfied for cases that have the same ID value in both datasets


This is still hard to decipher. Please show us some sample input data, and the desired output.

--
Paige Miller
Ranjeeta
Pyrite | Level 9

Please find attchd sample data

PaigeMiller
Diamond | Level 26

Many of us will not download and open MS Office documents as they are a security risk.

 

We need to see your data, preferably as a SAS data step, following these instructions https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... and we also need to see the desired output as well.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1633 views
  • 1 like
  • 2 in conversation