Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Data conversion
From
Chelsea Garneau <[email protected]>
To
[email protected]
Subject
Re: st: Data conversion
Date
Wed, 23 May 2012 10:44:32 -0400
Yes, Nick, I was mistaken, encode was the command to which I was
intending to refer. Thank you for clearing that up!
Chelsea
On Wed, May 23, 2012 at 10:37 AM, Nick Cox <[email protected]> wrote:
> Would that it were true that -destring- should "work" for any string variable.
>
> 1. -destring- is designed to convert numbers presenting as strings to
> the numbers they are entitled to be. Apart from some options to ignore
> common extras such as commas or dollar signs, it doesn't really
> purport to make numbers out of anything.
>
> 2. -destring- does not create its own coding system, by which I guess
> you mean value labels. I think you are confusing -destring- with
> -encode-.
>
> Hugo:
>
> I otherwise agree with Chelsea. We need more details on what the data
> look like and what you did.
>
> I don't understand how you expect to convert "la", "lb", etc. to
> numeric, but -encode- may be what you seek.
>
> Nick
>
> On Wed, May 23, 2012 at 3:23 PM, Chelsea Garneau
> <[email protected]> wrote:
>
>> How did you convert strings to dates? Were you using the destring
>> command? This command should work for any string variable. It will
>> create it's own coding system, I believe alphabetically, but you can
>> recode once it's in numerical format.
>
> On Wed, May 23, 2012 at 9:49 AM, Hugo Fontan Köhler <[email protected]> wrote:
>
>>> I have a database with (originally in bDase format, convertd to xls in
>>> Excel and imported in Stata) with a string variable in the format Ia,
>>> Ib, and so on. I want to convert this variable in a numeric one. I
>>> tried to generate a new variable with missing values (generate pZ=.)
>>> and use replace (replace pZ = 1 if Z="1"), but I always get a type
>>> mismatch error (r109). I managed to convert strings to dates but I
>>> can't convert to numbers.
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/