I have two dates in my SAS dataset that I would like to compare i.e., does date1 = date2. I attempted to do this using the ifn and ifc functions but have a suspicion they are not working correctly. I took this code directly from a sugi, but have worked with these functions successfully comparing character/numeric variables. I also successfully attempted the comparison using proc sql, but I want to learn to do this in a data step.
My code is below:
data not_in_HDD_3;
set not_in_HDD_2;
start=STMT_PERIOD_FROM;
if start=. then start=ADMIT_START_OF_CARE;
start_2=input(start, ANYDTDTE8.);
format start_2 MMDDYY10.;
drop start;
rename start_2=start;
dob=input(birth_date, ANYDTDTE8.);
format dob MMDDYY10.;
Birth_record = ifn (start eq dob, 0 , 1);
ifc_result = ifc(start=dob,"True","False","Missing");
ifn_result = ifn(start=dob,1,0,.);
ifn_result_fmt = put(ifn_result,ifn_label.);
fuzz_result = ifc(fuzz(start-dob),"True","False","Missing");
drop ifn_result;
run;
proc sql;
create table not_in_HDD_4 as
select *,
case
when (start=dob) then "True"
else "False"
end as sql_case_var length=8
from not_in_HDD_3;
quit;
Any insight is appreciated!
coalescefunction, return the first non-missing value.start = coalesce(STMT_PERIOD_FROM,ADMIT_START_OF_CARE). Also, I don't see any issues with your conditionals. Can add a portion of your dataset to your question? - J_Lard