Hello I want to create an exclusion criteria/variable for a large dataset that includes the variables PT_Number, date, status, and rank. I want to create an exclusion criteria so that I can later use a "Where" statement. I basically want this exclusion " If the dates where rank does not equal 1 and status does not equal P1 are less than the dates with the rank that equal 1 and status that equal P1 then the Exclusion_Variable will equal 1. *Note: there are other entries for rank such as (2,3,4) and for status such as (C1 CI, EA, etc). below is what I thought my code should look like and a table that I have and that I want. I also did test my code below and did a freq check and did not get any '1' in my exclusion variable frequency. Am I missing something? data Want;
set Have;
if date and rank ne 1 and status in ('C1,CI,EA,EB,F1,F2,F3,M1,M2,M4,M5,M7,M8,M9,MB,MH,MP,MS,N9,P1,P3,S4,VL,c1') < date and rank='1' and status='P1' then exclusion_variable='1';
run; Have PT_Number date status rank A1 22733 M1 1 A1 22733 P1 2 A1 22733 P1 1 A1 22733 P1 3 A1 22740 P1 2 A1 22740 P1 1 A1 22740 P1 1 A1 22740 P1 3 Want PT_Number date status rank Exclusion_Variable A1 22733 M1 1 1 A1 22733 P1 2 1 A1 22733 P1 1 A1 22733 P1 3 1 A1 22740 P1 2 A1 22740 P1 1 A1 22740 P1 1 A1 22740 P1 3
... View more