Given your BY statement: by uniqueid ptdob sex admitdte; 1) the first instance of the identifier (first.uniqueid, first.ptdob, first.admitdte, first.sex). Taken care of with the code above. Just use FIRST.ADMITDTE. You do not need to look at the other first. variables. 2) if first and last instance of all 4 identifying variables (i.e., only one incident per person). Also taken care of above, could add in some specific code if needed like: if (first.uniqueid and first.ptdob and first.admitdte and first.sex and last.uniqueid and last.ptdob and last.admitdte and last.sex) then do; Only one record per id would be tested by: (first.admitdte and last.admitdte) 3) if first instance of only one of the identifying variables, but not the first instance of the others >>e.g., if first.uniqueid=1 and first.ptdob=0, etc. ??? Scenario 3 is my problem. I've tried all sorts of combinations of first. and last. processing with 1 and 0, and am still not getting the right values for diff and casenum. If you want the first instance of the combination UNIQUEID,PTDOB and SEX then use FIRST.SEX. Again you do not need to look at all of them.
... View more