Hi all,
I need to generate the unique random number(dummy number) for character variable ID and it want to generate same number if it as same value.
The length of the Id has 26 but in the output dummy Id i would like to have only 15 character.
I have tried the below code but am not getting the answer what i expected.Please help me.
data test;
input id $;
datalines;
193684370_00000001325585921261_43329
193684370_00000001325580292526_40630
195983065_00000001325664113980_33853
193684319_00000001322303549331_21813
195983065_00000001325579363334_29482
;
run;
data test1;
set test;
id2=translate(id,'WQSVXTYRZU','0123456789');
run;
Thanks for your help.
data test;
input id $ 1-36;
datalines;
193684370_00000001325585921261_43329
193684370_00000001325580292526_40630
195983065_00000001325664113980_33853
193684319_00000001322303549331_21813
195983065_00000001325579363334_29482
;
run;
data test1;
length id2 $ 15;
set test;
id2=catx('-',translate(scan(id,1,'_'),'WQSVXTYRZU','0123456789'),translate(scan(id,3,'_'),'WQSVXTYRZU','0123456789'));
run;
proc print;run;
obs id2 id
1 QUVYZXVRW-XVVSU 193684370_00000001325585921261_43329
2 QUVYZXVRW-XWYVW 193684370_00000001325580292526_40630
3 QUTUZVWYT-VVZTV 195983065_00000001325664113980_33853
4 QUVYZXVQU-SQZQV 193684319_00000001322303549331_21813
5 QUTUZVWYT-SUXZS 195983065_00000001325579363334_29482
data test;
input id $ 1-36;
datalines;
193684370_00000001325585921261_43329
193684370_00000001325580292526_40630
195983065_00000001325664113980_33853
193684319_00000001322303549331_21813
195983065_00000001325579363334_29482
;
run;
data test1;
length id2 $ 15;
set test;
id2=catx('-',translate(scan(id,1,'_'),'WQSVXTYRZU','0123456789'),translate(scan(id,3,'_'),'WQSVXTYRZU','0123456789'));
run;
proc print;run;
obs id2 id
1 QUVYZXVRW-XVVSU 193684370_00000001325585921261_43329
2 QUVYZXVRW-XWYVW 193684370_00000001325580292526_40630
3 QUTUZVWYT-VVZTV 195983065_00000001325664113980_33853
4 QUVYZXVQU-SQZQV 193684319_00000001322303549331_21813
5 QUTUZVWYT-SUXZS 195983065_00000001325579363334_29482
Thanks Linlin.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.