I need to create a (simple?) error report from a dataset. The dataset looks like this:
Contract DrvrNum LicNum
------- ------- ---------
2212621 2 8241323
2212621 2 65256129
6385371 1 973385261
6385371 3 973385261
2366922 1 B931151BA
2366922 2 B931151BA
1007922 1 60916004
1007922 2 60916004
The first 2 observations indicate that I have two different license numbers for the same driver, whereas the next three pairs of observations indicate that a license number has been duplicated for two or more drivers.
My output needs to look like this:
Contract DrvrNum LicNum ErrorReason
------- ------- --------- -----------
2212621 2 8241323
2212621 2 65256129 Multiple License Numbers for Same Driver
6385371 1 973385261
6385371 3 973385261 Duplicate License Number
2366922 1 B931151BA
2366922 2 B931151BA Duplicate License Number
1007922 1 60916004
1007922 2 60916004 Duplicate License Number
I have tried using the LAG() function in a data step combined with first.Contract = 0, but because every other observation is FALSE, the lag values got all out of whack, keeping me from doing something like:
if LicNum = lag(LicNum) then ErrorReason = 'Duplicate License Number';
else ErrorReason = 'Multiple License Numbers for Same Driver';
If anyone can provide some assistance, I would be grateful. I'm at my wit's end with this one.
Thanks!
retain
ed variable. – Richard