Almost there. I tried the code below and it flags each line if duration is <= 45 regardless if member filled for a different drug or not. Trying to get it to flag where all the conditions are true. Same member, different drug, and <=45 days if that makes sense. Appreciate all the help.
data work.tbl_dup_conseq_02; set work.tbl_dup_conseq_01b; by src_member_id fill_dt drug_nm drug_class;
duration = intck("day", lag(fill_dt), fill_dt); if first.drug_nm=1 and first.src_member_id=0 and duration<=45 then flag = "Y"; /*drop duration;*/ run;
... View more