|
I need to create 100,000 unique random 7 digit alpha-numeric ID numbers. The
IDs have to have at least 3 letters and be unique to each case, they also need to be random so that the numbers are not sequential ie AAA1234, AAA1235, AAA1236. I know this is able to be done through python, but I don't have the ability to install the add on at my current location, so I was hoping that someoen would know of some syntax script to make random unique IDs. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
Don:
This code is a little bit cumbersome, but it generate a random id made up of 7 alpha characters. ***** random number generated for each character. do repeat x = d1 to d7. comp x = uniform (1). end repeat. string c1 to c7 (a1). do repeat Y = c1 to c7 /x = d1 to d7. IF range(X,0,0.0384615384615385) Y = 'Z'. IF range(X,0.0384615384615385,0.0769230769230769) Y = 'A'. IF range(X,0.0769230769230769,0.115384615384615) Y = 'B'. IF range(X,0.115384615384615,0.153846153846154) Y = 'C'. IF range(X,0.153846153846154,0.192307692307692) Y = 'D'. IF range(X,0.192307692307692,0.230769230769231) Y = 'E'. IF range(X,0.230769230769231,0.269230769230769) Y = 'F'. IF range(X,0.269230769230769,0.307692307692308) Y = 'G'. IF range(X,0.307692307692308,0.346153846153846) Y = 'H'. IF range(X,0.346153846153846,0.384615384615385) Y = 'I'. IF range(X,0.384615384615385,0.423076923076923) Y = 'J'. IF range(X,0.423076923076923,0.461538461538461) Y = 'K'. IF range(X,0.461538461538461,0.5) Y = 'L'. IF range(X,0.5,0.538461538461538) Y = 'M'. IF range(X,0.538461538461538,0.576923076923077) Y = 'N'. IF range(X,0.576923076923077,0.615384615384615) Y = 'O'. IF range(X,0.615384615384615,0.653846153846154) Y = 'P'. IF range(X,0.653846153846154,0.692307692307692) Y = 'Q'. IF range(X,0.692307692307692,0.730769230769231) Y = 'R'. IF range(X,0.730769230769231,0.769230769230769) Y = 'S'. IF range(X,0.769230769230769,0.807692307692307) Y = 'T'. IF range(X,0.807692307692307,0.846153846153846) Y = 'U'. IF range(X,0.846153846153846,0.884615384615384) Y = 'V'. IF range(X,0.884615384615384,0.923076923076923) Y = 'W'. IF range(X,0.923076923076923,0.961538461538461) Y = 'X'. IF range(X,0.961538461538461,1) Y = 'Y'. end repeat. STR ID (A7). comp id = concat(c1,c2,c3,c4,c5,c6,c7). freq id. You will need to sort and dedupe. I'm not sure if you have to have numeric characters, but each id will have at least 3 alpha characters :) --jim -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Don Asay Sent: Thursday, May 01, 2008 2:47 PM To: [hidden email] Subject: Creating Unique Random AlphaNumeric IDs I need to create 100,000 unique random 7 digit alpha-numeric ID numbers. The IDs have to have at least 3 letters and be unique to each case, they also need to be random so that the numbers are not sequential ie AAA1234, AAA1235, AAA1236. I know this is able to be done through python, but I don't have the ability to install the add on at my current location, so I was hoping that someoen would know of some syntax script to make random unique IDs. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by Björn Türoque
Hi Don,
Does this do what you want? (see syntax below). Cheers!! Albert-Jan INPUT PROGRAM. LOOP #i=1 TO 100000. COMPUTE #rannum1= trunc(rv.uniform(1000,9999)). COMPUTE #rannum2= trunc(rv.uniform(1,52)). COMPUTE #rannum3= trunc(rv.uniform(1,52)). COMPUTE #rannum4= trunc(rv.uniform(1,52)). STRING #alpha (a52) / id (A7). COMPUTE #alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz". COMPUTE id = CONCAT ( SUBSTR(#alpha, #rannum2, 1), SUBSTR(#alpha, #rannum3, 1), SUBSTR(#alpha, #rannum4, 1), STRING (#rannum1, F4) ). END CASE. END LOOP. END FILE. END INPUT PROGRAM. EXECUTE. AGGREGATE OUTFILE = * / BREAK = id / n = n. /* deduplication. --- Don Asay <[hidden email]> wrote: > I need to create 100,000 unique random 7 digit > alpha-numeric ID numbers. The > IDs have to have at least 3 letters and be unique to > each case, they also > need to be random so that the numbers are not > sequential ie AAA1234, > AAA1235, AAA1236. I know this is able to be done > through python, but I don't > have the ability to install the add on at my current > location, so I was > hoping that someoen would know of some syntax script > to make random unique > IDs. > > ===================== > To manage your subscription to SPSSX-L, send a > message to > [hidden email] (not to SPSSX-L), with no > body text except the > command. To leave the list, send the command > SIGNOFF SPSSX-L > For a list of commands to manage subscriptions, send > the command > INFO REFCARD > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
