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

st: Re: question about converting string vars to numerical vars

From   Friedrich Huebler <[email protected]>
To   [email protected]
Subject   st: Re: question about converting string vars to numerical vars
Date   Wed, 26 Jan 2005 09:53:29 -0800 (PST)


You can also use the command -destring- to convert string variables
to numeric variables. The encode entry in the Stata Reference Manual
states: "Do not use encode if varname contains numbers that merely
happen to be stored as strings; instead use generate
newvar=real(varname) or destring."

Friedrich Huebler

--- Joy Chen <[email protected]> wrote:
> I wonder if anyone knows to how to solve this problem. I have a
> .txt data
> and I used -insheet using data1.txt, t- to import it into stata. It
> shows
> that the display type of the variables are string variable. I tried
> to
> convert them into numerical vars. I replaced #.# in -format- 
> command with
> #,#  as it is European decimal symbol (the comma) used in data.
> After many
> trials, it still gives me strange result. The mean, max and min of
> the
> variables are far away from the truth.  For example, the mean for
> e1 should
> be -0,27145726 but stata gives 1,64654, for f1 the true mean is
> 0,49880390,
> in stata is  2,299758 .
> Did I make some mistake in the code? Can anyone give me a hand?

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index