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

Re: st: mata problem: convert sting to real


From   wgould@stata.com (William Gould, Stata)
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: mata problem: convert sting to real
Date   Tue, 09 Aug 2005 08:30:41 -0500

Ben Jann <ben.jann@soz.gess.ethz.ch> wrote

> Some weeks ago I posted a mata function called -realofstr()- 
> on SSC. The function can be used to convert string elements 
> into numeric values. See -ssc d mf_realofstr-.
> 
> I don't like -realofstr()- because it makes use of Stata 
> commands. The task - converting sting to real - is so basic 
> that I think there should be a genuine mata solution without 
> any Stata in it.
> 
> Note that the reverse - real to string - is a built-in
> Mata function. See -help mata strofreal()-. The fact that 
> official Mata has a -strofreal()- function but not a 
> -realofstr()- function makes me suspect that the latter is 
> not really needed. There must be some ridiculously simple 
> way to covert string to real, but I just don't see it. Can
> anyone help me? 

In the next executable update, Mata will include a new function 
-strtoreal()- that will perform conversions.  That -strtoreal()-
was omitted from the original release was an oversight, and one 
that was bothering me as much as it was bothering Ben.  In the
meantime, my solution has  been the same as Ben's -- write 
a function to perform the conversion, and then implement 
that function in terms of Stata.

-- Bill
wgould@stata.com
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index