BookmarkSubscribeRSS Feed
radhikaa4
Calcite | Level 5

Hello,

 

I have 2 datasets and I would like to create 3rd dataset 

 

Dataset #1

 

patientIDdatevolume
44441/2/201445
44441/3/201450
44441/4/201412
44441/5/201433
44441/6/201412
32331/6/201566
32331/7/201535
32331/9/201523

 

Dataset #2

patientIDdateflag
44441/4/20141
32331/7/20151

 

Want dataset #3

patientIDdatevolumeflag
44441/2/201445 
44441/3/201450 
44441/4/2014121
44441/5/201433 
44441/6/201412 
32331/6/201566 
32331/7/2015351
32331/9/201523 

 

I tried the following

PROC SQL;

SELECT bb.*, cc.flag

FROM a.dataset_1 bb LEFT JOIN a.dataset_2 cc on bb.patientID = cc.patientID;

QUIT;

 

But it doesn't work or shows "flag = 1" for all the records. I also tried full outer join etc. 


Thanks

1 REPLY 1
Reeza
Super User
Add a condition to join on date as well.

and bb.date=cc.date

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 1 reply
  • 366 views
  • 0 likes
  • 2 in conversation