Hi,
Hope everybody is doing well. I just want to ask if someone can look at the code I wrote if it's correct and if there's a way to shorten it.
Thanks in advance,
below is the code:
data Cust_Loc; set Cust_wLoans2 (drop=Dist);
if Store_Is_Open = 0 then do;
if (LOC_Inst_loc in (&closed_loc) or LOc_Inst_loc in (&web_loc)) and PDL_Loc = . and Service_Loc = . then Home_Branch = nearest_location;
if (LOC_Inst_loc in (&closed_loc) or LOc_Inst_loc in (&web_loc)) and PDL_Loc ne . and Service_Loc = . then Home_Branch = nearest_location;
if (LOC_Inst_loc in (&closed_loc) or LOc_Inst_loc in (&web_loc)) and PDL_Loc ne . and Service_Loc ne . then Home_Branch = nearest_location;
if (LOC_Inst_loc in (&closed_loc) or LOc_Inst_loc in (&web_loc)) and PDL_Loc = . and Service_Loc ne . then Home_Branch = nearest_location;
if (LOC_Inst_loc not in (&closed_loc) and LOc_Inst_loc not in (&web_loc)) and PDL_Loc = . and Service_Loc = . then Home_Branch = LOC_Inst_Loc;
if (LOC_Inst_loc not in (&closed_loc) and LOc_Inst_loc not in (&web_loc)) and PDL_Loc ne . and Service_Loc = . then Home_Branch = LOC_Inst_Loc;
if (LOC_Inst_loc not in (&closed_loc) and LOc_Inst_loc not in (&web_loc)) and PDL_Loc ne . and Service_Loc ne . then Home_Branch = LOC_Inst_Loc;
if (LOC_Inst_loc not in (&closed_loc) and LOc_Inst_loc not in (&web_loc)) and PDL_Loc = . and Service_Loc ne . then Home_Branch = LOC_Inst_Loc;
if LOC_Inst_Loc = . and (PDL_Loc in (&closed_loc) or PDL_Loc in (&web_loc)) and Service_Loc = . then Home_Branch = nearest_location;
if LOC_Inst_Loc = . and (PDL_Loc in (&closed_loc) or PDL_Loc in (&web_loc)) and Service_Loc ne . then Home_Branch = nearest_location;
if LOC_Inst_Loc = . and (PDL_Loc not in (&closed_loc) and PDL_Loc not in (&web_loc)) and Service_Loc = . then Home_Branch = PDL_Loc;
if LOC_Inst_Loc = . and (PDL_Loc not in (&closed_loc) and PDL_Loc not in (&web_loc)) and Service_Loc ne . then Home_Branch = PDL_Loc;
if LOC_Inst_Loc = . and PDL_Loc = . and Service_Loc in (&closed_loc) then Home_Branch = nearest_location;
if LOC_Inst_Loc = . and PDL_Loc = . and Service_Loc not in (&closed_loc) then Home_Branch = Service_Loc;
end;
if Store_Is_Open = 1 then do;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc not in (&web_loc)) and PDL_Loc = . and Service_Loc = . then Home_Branch = LOC_Inst_Loc;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc not in (&web_loc)) and PDL_Loc ne . and Service_Loc = . then Home_Branch = LOC_Inst_Loc;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc not in (&web_loc)) and PDL_Loc ne . and Service_Loc ne . then Home_Branch = LOC_Inst_Loc;
if LOC_Inst_loc = . and (PDL_Loc ne . and PDL_loc not in (&web_loc)) and Service_loc = . then Home_Branch = PDL_Loc;
if LOC_Inst_loc = . and (PDL_Loc ne . and PDL_loc not in (&web_loc)) and Service_loc ne . then Home_Branch = PDL_Loc;
if LOC_Inst_loc = . and PDL_Loc = . and (Service_loc ne . and Service_loc not in (&web_loc)) then Home_Branch = Service_loc;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc in (&web_loc)) and PDL_Loc = . and Service_Loc = . then Home_Branch = nearest_location;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc in (&web_loc)) and PDL_Loc ne . and Service_Loc = . then Home_Branch = nearest_location;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc in (&web_loc)) and PDL_Loc ne . and Service_Loc ne . then Home_Branch = nearest_location;
if LOC_Inst_loc = . and (PDL_Loc ne . and PDL_loc in (&web_loc)) and Service_loc = . then Home_Branch = nearest_location;
if LOC_Inst_loc = . and (PDL_Loc ne . and PDL_loc in (&web_loc)) and Service_loc ne . then Home_Branch = nearest_location;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc not in (&web_loc)) and PDL_Loc = . and Service_Loc ne . then Home_Branch = LOC_Inst_Loc;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc in (&web_loc)) and PDL_Loc = . and Service_Loc ne . then Home_Branch = Service_Loc;
if LOC_Inst_Loc = . and PDL_Loc = . and Service_Loc = . then Home_Branch = nearest_location;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc in (&closed_loc)) and PDL_Loc = . and Service_Loc = . then Home_Branch = Nearest_Location;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc in (&closed_loc)) and PDL_Loc ne . and Service_Loc = . then Home_Branch = Nearest_Location;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc in (&closed_loc)) and PDL_Loc ne . and Service_Loc ne . then Home_Branch = Nearest_Location;
if (LOC_Inst_Loc ne . and LOC_Inst_Loc in (&closed_loc)) and PDL_Loc = . and Service_Loc ne . then Home_Branch = Nearest_Location;
if LOC_Inst_loc = . and (PDL_Loc ne . and PDL_loc in (&closed_loc)) and Service_loc = . then Home_Branch = Nearest_Location;
if LOC_Inst_loc = . and (PDL_Loc ne . and PDL_loc in (&closed_loc)) and Service_loc ne . then Home_Branch = Nearest_Location;
if LOC_Inst_Loc in (&web_loc) and PDL_Loc = . and Service_Loc in (&closed_loc) then Home_Branch = Nearest_Location;
end;
format Home_Branch best.;
;run;