There are several ways it can be done. For example, with a macro foo that is numeric we could do this:
local words "one two three four five six seven eight nine ten"
local bar "`foo'"
forval i = 1/10 {
if "`foo'" == "`i'" local bar : word `i' of words
}
di "`bar'"
You could use similar logic with a variable. Clearly you would to use a string variable as result.
Alternatively, define value labels.
Alternatively, use -subinstr()-.
Nick
[email protected]
Jan Sauermann
I use Stata to store certain numbers in text-files in order to include
these in the text of my Latex-file (which is pretty handy, by the
way).
Some numbers (integers only) are pretty small, say 2. Is there a way
to convert a number "2" into a string with content "two" in Stata?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/