Thank you for all the help.
I have almost figured it out but I seem to have a problem with duplicate IDs, when I do it this way... Because the random IDs are generated separately for those with blank ID1s and those with non blank ID1s, there seems to be duplicate IDs.
I just need to fix the problem with duplicate random P_IDs, everything else works perfectly it seems.
Data want;
set have;
attrib P_ID length=$10 label='Person ID';
attrib T_ID length=5 label='Transaction ID';
by ID1;
retain P_ID T_ID;
if first.ID1 and ID1 NE '' then do;
P_ID = CATS ("X_", put(int(ranuni(26298)*1e6)+1,z 6.) );
T_ID=1;
end;
else if ID1 = '' then do;
P_ID = CATS ("X_", put(int(ranuni(58787)*1e6)+1,z 6.) );
T_ID=1;
end;
else T_ID+1;
run;
... View more