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

st: identifying last name/first name inversions inadministrative datasets


From   Pierre Azoulay <[email protected]>
To   [email protected]
Subject   st: identifying last name/first name inversions inadministrative datasets
Date   Wed, 12 Oct 2005 22:52:42 -0400

Let me thank you for your suggestions and share with you the solution
I adopted, coutesy of the stata help desk:

. generate newid =0

. forvalues i = 1/`=_N' {
  2.   quietly replace newid = `i' if inlist(fname,fname[`i'],lname[`i']) ///
>           & inlist(lname,fname[`i'],lname[`i'])
  3. }

. list fname lname newid, clean

           fname       lname   newid
  1.       Knuth   Alexander      11
  2.       Knuth   Alexander      11
  3.       Knuth   Alexander      11
  4.       Knuth   Alexander      11
  5.   Alexander       Knuth      11
  6.   Alexander       Knuth      11
  7.   Alexander       Knuth      11
  8.   Alexander       Knuth      11
  9.   Alexander       Knuth      11
 10.   Alexander       Knuth      11
 11.   Alexander       Knuth      11
 12.         Bob        Hope      13
 13.        Hope         Bob      13
 14.         Bob      Howard      15
 15.      Howard         Bob      15

----------------------------------------------------------------------------------
Pierre Azoulay
Associate Professor of Management
Columbia University                           Phone: (212) 854-9684
Graduate School of Business                Fax:   Don't send any
3022 Broadway, Uris Hall 704
New York, NY 10023                        http://www.columbia.edu/~pa2009/

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