Hi,
I have a Mata problem that drives me crazy.
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? Bill?
Furthermore, note that, naturally, mata can do the conversion
of string to real in interactive mode. For example, if you
type
: r = 1.2
mata sees the string "1.2" and thinks: "Well this must be a
number, so let's store it as a real scalar." But how can the
conversion be done none-interactively?
Thanks in advance,
ben
*
* 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/