I am getting error for this code, not knowing where I am missing.
data want;
data have;
if centre in ('Shai','Hub','imen') and Date_of_Birth between mdy(3,01,1953) and mdy(6,30,1974) then status = 'pass';
run;
Not sure where I am missing, I tried with where as well but not succeeding, apart from that also checked with do end , But could not get the required result, Can any one help on this
Thanks
Seems like you need set statement
data want;
set have;
if centre in ('Shai','Hub','imen') and Date_of_Birth between mdy(3,01,1953) and mdy(6,30,1974) then status = 'pass';
run;
Agree with you,
Actually it has to be
Data want;
set have;
run;
It was a typo sorry for that. However running the mentioned codes by replacing with Set is not deriving the expected result
Hello Reeza,
I got the solution, However if I use 'between and' for a date, and if I use 'Where' or 'IF' I am not getting the expected results, is it like if I am using 'between and' for a date can't I use 'where' and 'IF'
Thanks,
Try:
if centre in ('Shai','Hub','imen') and (mdy(3,01,1953) le Date_of_Birth le mdy(6,30,1974)) then status = 'pass';
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!
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.