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

Re: st: Re: Unique Identifier


From   "R.E. De Hoyos" <[email protected]>
To   <[email protected]>
Subject   Re: st: Re: Unique Identifier
Date   Mon, 5 Jan 2004 18:29:11 -0000

Have you tried "destring" before egen?


----- Original Message ----- 
From: "Tim Wade" <[email protected]>
To: <[email protected]>
Cc: <[email protected]>
Sent: Monday, January 05, 2004 5:53 PM
Subject: Re: st: Re: Unique Identifier


> --- Janet Oliver <[email protected]> wrote:
> > I have a dataset that consists of a name (of various
> > lengths), a treatment
> > and a time period (0..5) with not all patients being
> > seen at the six times,
> > and various clinical results. I wanted to create a
> > unique numerical
> > identifier based on name|treatment|time. I initally
> > concatenated the
> > variables "egen tid=concat(patient treat time)" and
> > the tried to destring
> > tid but this failed with the error message "tid
> > contains non-numeric
> > characters; no generate". I have examined the
> > variables in the editor and
> > cannot see any non-numeric characters.
> > My questions are 1) Is there any way of determining
> > non-numeric characters
> > or 2) Is there an efficient method of combing
> > name|treatment|time and
> > generating a unique ID (preferably starting at 1 and
> > increasing
> > sequentially) - or should I just type in the IDs by
> > hands.
> > Many thanks.
> > Janet
> 
> 
> Janet, if you haven't done it already you can use
> "describe" to confirm that the variables are numeric.
> Although they may look like numbers the may actually
> be stored as character, depending on how the data set
> was created. To convert a character to a numeric, you
> can use the "real" function, e.g., gen
> num=real(string)
> 
> To help you identify unique observations, you may be
> able to use explicit subscripting, e.g. "_n", see the
> USer's Manual, or help for subscripting.
> 
> 
> 
> 
> __________________________________
> Do you Yahoo!?
> Find out what made the Top Yahoo! Searches of 2003
> http://search.yahoo.com/top2003
> *
> *   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