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

You are right. I reran in the morning again. It worked.

 

Big Big Thank you for this help!!!

d0816
Quartz | Level 8

This code is giving me unmatched PINs as well from dataset y since code says left join and where condition did not work.

SuryaKiran
Meteorite | Level 14

Is this what your looking for?

 

data dataset1;
infile datalines dlm='09'x ;
format Date yymmdd10.;
input ID :$15.	Date :yymmdd10.;
datalines;
0000000101	2017-03-22
0000000104	2017-06-20
0000000105	2017-05-17
0000000106	2017-06-20
0000000108	2017-10-12
0000000109	2017-11-01
0000000110	2017-11-08
0000000111	2017-08-01
0000000112	2017-06-14
0000000113	2017-09-19
0000000114	2017-07-23
;
quit;

data dataset2;
format SessionBeginDate SessionEndDate  yymmdd10.;
infile datalines dlm='09'x missover;
input ID :$15.	SessionCode :$3.	SessionBeginDate :yymmdd10.	SessionEndDate :yymmdd10.;
datalines;
0000000101	E	2018-03-26	2018-04-09
0000000101	W	2018-04-09	 
0000000102	C	2018-01-31	2018-05-30
0000000102	M	2018-03-05	2018-05-30
0000000102	S	2018-01-31	2018-05-30
0000000103	U	2016-10-18	 
0000000103	W	2018-03-23	 
0000000103	C	2016-10-19	 
0000000103	M	2016-10-19	 
0000000103	S	2016-10-26	 
0000000104	J	2017-04-28	 
0000000104	F	2017-04-28	 
0000000105	J	2017-12-11	2018-04-30
0000000105	F	2017-12-11	2018-04-30
0000000106	M	2018-03-13	 
0000000106	S	2015-05-14	 
0000000106	W	2018-03-19	2018-05-22
0000000107	M	2017-01-18	 
0000000107	S	2017-01-17	 
0000000108	M	2017-12-18	 
0000000108	S	2017-10-03	 
0000000109	J	2017-09-22	 
0000000109	S	2016-01-04	 
0000000109	F	2017-09-22	 
0000000110	C	2017-08-28	 
0000000110	M	2017-08-28	 
0000000110	S	2013-02-14	 
0000000111	C	2017-11-13	2018-04-17
0000000111	C	2018-04-18	 
0000000111	M	2017-11-13	2018-04-17
0000000111	M	2018-04-18	 
0000000111	S	2017-11-13	2018-04-17
0000000111	S	2018-04-18	 
0000000112	M	2017-08-09	2018-04-05
0000000112	S	2017-07-31	2018-04-05
0000000113	A	2018-04-17	 
0000000113	M	2018-04-17	 
0000000113	C	2017-09-19	2018-04-16
0000000113	C	2017-09-19	2018-04-16
0000000113	M	2017-09-19	2018-04-16
0000000113	M	2018-04-17	 
0000000113	S	2016-09-20	 
0000000114	M	2018-02-19	 
0000000114	S	2017-07-07	 
0000000115	E	2018-03-29	2018-05-15
0000000115	J	2018-03-30	 
0000000115	P	2018-03-30	2018-05-14
0000000115	E	2018-03-29	2018-05-15
0000000115	J	2018-03-30	 
0000000115	P	2018-03-30	2018-05-14
;
run;


Proc SQL;
Create Table want as 
select y.*
from  dataset2 y
	left join dataset1 x
		on x.ID=y.ID
Where (x.Date between y.SessionBeginDate and y.SessionEndDate) 
	or
	  (x.Date GE y.SessionBeginDate and y.SessionEndDate is null );
Quit;
Thanks,
Suryakiran

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!

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