Help using Base SAS procedures

Create Dummy Number

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 90
Accepted Solution

Create Dummy Number

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.


Accepted Solutions
Solution
‎10-02-2012 01:23 PM
Super Contributor
Posts: 1,636

Re: Create Dummy Number

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

View solution in original post


All Replies
Solution
‎10-02-2012 01:23 PM
Super Contributor
Posts: 1,636

Re: Create Dummy Number

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

Frequent Contributor
Posts: 90

Re: Create Dummy Number

Thanks Linlin.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 188 views
  • 0 likes
  • 2 in conversation