In addition, a fairly strung-out discussion is given
in "On numbers and strings" Stata Journal 2(3):314--329
(2002). That needs updating on the detail that -tostring-
is now part of official Stata.
The main story there is to think of methods as coming
in pairs:
-encode- and -decode- for strings vs numeric variables
with value labels;
-tostring- and -destring- for when the present variable
type is essentially a mistake (perhaps yours, perhaps
Stata's)
-real()- and -string()- as the brute force conversion
functions.
Another pair is -sencode- and -sdecode-, which are "super" versions of
-encode- and -decode-, respectively. Both are downloadable from SSC using
the -ssc- command in Stata.