Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: creating unique identifier values


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: st: creating unique identifier values
Date   Wed, 8 Mar 2006 21:06:00 -0500

No idea why you would want to do it, but it's easy with -forval-

clear
 set obs `=26*35'
 g x=.
 g a=.
 g i=.
 local n=1
forv i=1/26 {
    forv a=1/35 {
     qui  replace x=`i'`a' in `n'
     qui  replace i=`i'  in `n'
     qui  replace a=`a' in `n'
   local n=`n'+1
  }
}


On 3/8/06, Suzy <[email protected]> wrote:
> I am entering in some data manually and I would like to be able to
> quickly insert unique numeric identifiers which represent 26 individual
> subjects each with 35 attributes.
>
>         The values for the individual identifiers look like this:
>
>  subject 1 with 1-35 attributes =
> 11,12,13,14,....110,111,112...120,121,122...130,131,132,133,134,135
>  subject 2 with 1-35 attributes =
> 21,22,23,24,....210,211,212...220,221,222...230,231,232,233,234,235
>  subject 3 with 1-35 attributes =
> 31,32,33,34.....310,311,312...320,321,322...330,331,332,333,334,335
>
> etc. to subject 26 w/ 1-35 attributes...261,262,263
>
> These values will be manually inputted in one column under varname (obs)
> in ascending order of subject number(s) and attribute number(s).
>
> obs
> 11
> 12
> 13
> 14
> .etc
> .etc
> 110
> 111
> 112
> .etc
> .etc
> .etc
> 21
> 22
> 23
> 24
> 25
> .etc
> .etc
> .etc
>
> I'm wondering if there is Stata listmember that could generate these
> values via Stata coding and would be willing to share that information.
>
> Thank you!
> Suzy
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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