Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: string to numeric(non-numeric)


From   Maarten buis <[email protected]>
To   stata list <[email protected]>
Subject   st: RE: string to numeric(non-numeric)
Date   Mon, 7 Apr 2008 11:49:26 +0100 (BST)

The problem is the comma, so you should type:
destring malespop, gen(MalesNum) ignore(",")

Hope this helps,
Maarten

--- Gauri Khanna wrote
> I am trying to convert a string variable(malespop) to a numeric 
> variable. I tried to the following:
>
> -destring malespop, generate(MalesNum)-
> -destring malespop, replace
> -destring males, gen(MalesNum) ignore(" ")
> 
> but with each of these I got the following error:
> 
> - malespop contains non-numeric characters; no generate-
> 
> I tried to use -mvencode- but that did not work too. I tried -gen 
> MalesNum=real(malespop) but got missing values for all entries!
>
> My data looks like this and has blanks in between for no values:
> 
> SNo. malespop
> 
> 1. 45,623
> 2.
> 3. 67,345,119
> 4.
> 5.
> 6. 3406
> 7. 56,670,986
> 8.

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room Z434

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      ___________________________________________________________ 
Yahoo! For Good helps you make a difference  

http://uk.promotions.yahoo.com/forgood/
*
*   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