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]

From |
Gwinyai Masukume <parturitions@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: problem converting a string variable to a numeric variable |

Date |
Thu, 25 Apr 2013 22:23:48 +0200 |

Many thanks Nick. Do you sleep? Just kidding. Kind regards, Gwinyai On 4/25/13, Nick Cox <njcoxstata@gmail.com> wrote: > For one overview of this territory see > > SJ-2-3 pr0006 . . . . . . . . . . . . Speaking Stata: On numbers and > strings > . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. > Cox > Q3/02 SJ 2(3):314--329 (no > commands) > explains the use of numeric and string data types in Stata > and how to convert from one kind to another > > See http://www.stata-journal.com/sjpdf.html?articlenum=pr0006 for > accessible .pdf. > > It's slightly out-of-date (-tostring- became an official command after > that paper) but the main ideas still apply. > > Nick > njcoxstata@gmail.com > > > On 25 April 2013 19:50, Gwinyai Masukume <parturitions@gmail.com> wrote: >> Thanks Elan. >> Kind regards, >> Gwinyai >> >> On 4/25/13, Cohen, Elan <cohened@upmc.edu> wrote: >>> -encode- is the wrong command for this job. (Read the help file more >>> closely to understand why.) >>> >>> Try -destring-. >>> >>> - Elan >>> >>> >>> -----Original Message----- >>> From: owner-statalist@hsphsun2.harvard.edu >>> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Gwinyai >>> Masukume >>> Sent: Thursday, April 25, 2013 13:18 >>> To: statalist >>> Subject: st: problem converting a string variable to a numeric variable >>> >>> Dear Stata listers, >>> >>> I have a variable weight. The original dataset has weight as a string >>> variable. Type - str13 >>> Format - %13s. >>> >>> encode weight, generate(weightgrams) >>> >>> The above code apparently creates a numeric variable weightgrams. >>> Type - long >>> Format - %13.0g >>> >>> However when dealing with this new variable e.g summ weightgrams, I get >>> completely abnormal results which bear no resemblance to the expected >>> results for the variable weight. >>> >>> I suspect there is some kind of error in conversion from a string to >>> numeric variable. >>> >>> I am using version 12.1 >>> >>> Kind regards, >>> Gwinyai >>> * >>> * For searches and help try: >>> * http://www.stata.com/help.cgi?search >>> * http://www.stata.com/support/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/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/faqs/resources/statalist-faq/ * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: RE: problem converting a string variable to a numeric variable***From:*Donald Spady <dspady@ualberta.ca>

**References**:**st: problem converting a string variable to a numeric variable***From:*Gwinyai Masukume <parturitions@gmail.com>

**st: RE: problem converting a string variable to a numeric variable***From:*"Cohen, Elan" <cohened@upmc.edu>

**Re: st: RE: problem converting a string variable to a numeric variable***From:*Gwinyai Masukume <parturitions@gmail.com>

**Re: st: RE: problem converting a string variable to a numeric variable***From:*Nick Cox <njcoxstata@gmail.com>

- Prev by Date:
**Re: st: RE: problem converting a string variable to a numeric variable** - Next by Date:
**st: collinearity in categorical variables** - Previous by thread:
**Re: st: RE: problem converting a string variable to a numeric variable** - Next by thread:
**Re: st: RE: problem converting a string variable to a numeric variable** - Index(es):