Hellow, it wer me, I would do it like this data one; input id visit test $ val ptnum date $19.; datalines; 1 1 temp 88 2 2010-04-27 1 1 temp 90 2 2010-04-28 1 1 temp 92 2 2010-04-29 2 1 temp 100 2 2010-05-27 2 1 temp 98 2 2010-05-28 2 1 temp 96 2 2010-05-29 3 1 temp 100 2 2010-05-27 3 1 temp 98 2 2010-05-28 3 1 temp . 2 2010-05-29 ; run ; /* Insert step1 */ data ONE ; set ONE ; DUMMY_DATE = ^(missing(VAL)) * input(DATE, yymmdd10.) ; run ; proc sort data=one; by id test visit ptnum DUMMY_DATE; run; data two(drop=DUMMY_DATE); set one; by id test visit ptnum DUMMY_DATE; if last.ptnum then flag='Y'; run; /* Insert step2 */ proc sort data=two; by id test visit ptnum date; run;
... View more