[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

# st: AW: How to create a random number identifier number

 From "Martin Weiss" <[email protected]> To <[email protected]> Subject st: AW: How to create a random number identifier number Date Thu, 12 Nov 2009 09:20:36 +0100

```<>

Anna could also create the identifiers as

*************
clear*

//get the universe of possible 5 digits
set obs 90001
gen newpersonid=_n+9999

//get 11.000 w/o replacement
sample 11000, cou

//see what happened
desc
isid newpersonid
*************

save this to a -tempfile-, load her original dataset and -merge- by
observation.

HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Anna Reimondos
Gesendet: Donnerstag, 12. November 2009 03:38
An: [email protected]
Betreff: st: How to create a random number identifier number

Hello,
I am experiencing problems creating a unique set of number for my dataset.

I have a dataset with around 11,000 subjects or persons, and each one
of these subjects has a unique identifier that is 5 digits long
(personid).
I need to create a concordance file which list the original 5 digit
"personid" and matches this to another new randomly created identifier
for each person. This new identifier (new_personid) also has to be 5
digits long.

Example:
personid   new_personid
10526        35624
18594        21893
54632        12489

I have tried playing around with the gen  x = uniform() function but
to no avail. I am unable to create exactly 11,000 unique numbers with
5 digits.
I also tried just using the egen x=se() command, but then the ids are
sequential and not random and I am afraid then perhaps someone could
figure out how to match the personid and the newperson id....

Any help would be much appreciated,

Thanks
Anna

(Using STATA 10.1, Windows Vista)

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```

 © Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index