I have two ways of doing the same thing but am not getting the same results. what is the reason for this?
First way:
Proc sql;
Create table abc.immu as
select ID, DATE, CODE
from xyz.imm
where DATE between to_date('2008-01-01','YYYY-MM-DD') and to_date('2016-01-31','YYYY-MM-DD')
Order by CODE);
Quit;
Proc sql ;
Create table abc.testb as
select CODE, description from xyz.REF_code where lower(description)like '%hep b%';
Quit;
proc sort data=abc.testb;
by code;
run;
data abc.testb1;
merge abc.immu(in=a) abc.testb (in=b);
by code;
if a=1 and b=1;
run;
Second way
Create table abc.testb1 as
Select ID, DATE,CODE
From xyz.imm
where CODE in (select CODE from xyz.REF_code where lower(description)like '%hep b%')
AND DATE between to_date('2008-01-01','YYYY-MM-DD') and to_date('2016-01-31','YYYY-MM-DD')
Order by ID, DATE;
Quit;
proc sort data=abc.testb1 nodupkey;
by ID DATE;
run;
Why am not getting the same result? is it not two different ways to achieve same thing?