Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: how to create case id number


From   "Eric G. Wruck" <[email protected]>
To   [email protected]
Subject   Re: st: how to create case id number
Date   Fri, 29 Apr 2005 10:56:12 -0400

Stata does very little automatically.  One thing that it does do automatically is create a variable _n that contains the observation number or record number.  However, as soon as you sort or do something with the data set, these _ns will change.  So, to create the variable you seem to want, you'll want to use the generate command (usually abbreviated gen):

gen case_id = _n


I encourage you to play with Stata, including the very good help facilities.  You'll learn a lot quickly by simply diving in!  Good luck.


Eric



>Is there a STATA command that automatically generates a case id for each
>record in a dataset?
>
>Thank you for your help in advance.
>
>Seok-Woo Kwon
>Email: [email protected]



-- 

===================================================

       Eric G. Wruck
       Econalytics
       2535 Sherwood Road
       Columbus, OH  43209

       ph:      614.231.5034
       cell:    614.327.4182
       fax:     614.231.5039
       eFax:    614.573.6639
       eMail:   [email protected]
       website: http://www.econalytics.com

====================================================
*
*   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