Here is the Problem:
- Assume you have a SAS data set (called CLAIMS) that contains pharmacy claims. Each claim should be uniquely identified by the patient's identification number (ID_NUM) and a transaction number (Claim_Num). (E.g., patient 001 should not have more than one record with Claim_Num = 123). You want to be able to inspect any claims for which there are possible duplicate records. Write the SAS code to separate the observations into 2 new SAS data sets. One data set will hold all the observations where the combination of ID_NUM and Claim_Num are unduplicated (that is, there is only one claim with a particular ID_NUM and Claim_Num combination), and a second data set that will hold all the records (including the first) where there are duplicates of Claim_Num for a given ID_NUM. (HINT: you will need to use first. and last. to do this).
Here is what I have:
proc sort data=CLAIMS;
by ID_NUM CLAIM_NUM;
run;
data CLAIMS1 Claims2;
set CLAIMS;
by ID_NUM CLAIM_NUM;
if first.ID_NUM = 1;
Output Claims1;
if first.ID_NUM = 1 and last.ID_NUM = 1;
Output Claims2;
run;
I know this is wrong because I tried a sample data set and there was no output for claims2. I think the error is first.id_num being = to 1 in both cases but I just can't think of how to properly separate the two sets of data. If anyone can help me figure out this problem, it would be greatly appreciated. Thank you.