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

RE: st: create unique variables


From   Kieran McCaul <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   RE: st: create unique variables
Date   Sun, 6 Feb 2005 10:50:20 +0800

A potential problem with using egen like this is that it depends on
firstname and lastname being entered in your data in a consistent manner.

For example "Smith" amd "SMITH" will be treated as different, as will
"SMITH" and "SMITH  ".

What I would do first is trim all the names and convert them all the upper
case:

gen name1=trim(upper(firstname))
gen name2=trim(upper(lastname))

egen id = group(name1 name2 dob)

Kieran


-----Original Message-----
From: [email protected]
[mailto:[email protected]]On Behalf Of David Harrison
Sent: Friday, 4 February 2005 7:07 PM
To: [email protected]
Subject: RE: st: create unique variables


While both of the suggestions so far work fine, what is wrong with just:

egen id=group(firstname lastname dob)

David
[email protected]

-----Original Message-----
From: Fouarge.j. [mailto:[email protected]]
Sent: 04 February 2005 10:58
To: [email protected]
Subject: Re: st: create unique variables


you could try this (assuming var a = last name, b = first name, ...):
sort a b c 
gen tel=_n
by a b c: egen pid=min(tel)
drop tel

didier


-----Original Message-----
From: "Paolo Grillo, MD" <[email protected]>
To: [email protected]
Date: Fri, 04 Feb 2005 10:13:10 +0100
Subject: st: create unique variables

I have a dataset with the following variables:

last name
first name
date of birth

Since this dataset contains more than one record for individual, I would 
create a  unique variable for subject (ID).
Could anyone help me in this problem?
Thank in advance

-- 



* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 

Paolo Grillo MD
Nephrologist 
Statisticians
EPOCA Research Center for Occupational, Clinical & Environmental
Epidemiology
Department of Occupational and Environmental Health "Clinica L. Devoto"
University of Milan
Via San Barnaba 8
20122 Milano - ITALY
Tel: +39 02 503-20148
Fax: +39 02 503-20126
E-Mail [email protected]



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


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