[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: mata problem: convert sting to real
Ben Jann <firstname.lastname@example.org> 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.
* For searches and help try: