use subinstr(), e.g.,
subinstr(var1,",","",.)
and then use real()
At 10:06 AM 12/23/2003 -0800, you wrote:
I am trying to convert a series of string variables to numeric variables.
Because some of the numbers contain commas, the real() function does not
work, instead returning a missing value.
What I get
String Number
5.3 5.3
hello .
>2 .
2,500,000 .
What I want to get
String Number
5.3 5.3
hello .
>2 2
2,500,000 2500000
Is there any way to extract a numeric value from the string variable?
Thanks,
Shawn
*
* 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/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jesper B. S�rensen
Richard S. Leghorn (1939) Associate Professor of Strategic Management
Sloan School of Management
Massachusetts Institute of Technology
E52-581
Cambridge, MA 02142
http://web.mit.edu/sorensen/www/
(617) 253 7945 -- voice
(617) 253 2660 -- fax
*
* 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/