Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: writing out numbers ("two" instead of "2")


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: writing out numbers ("two" instead of "2")
Date   Fri, 9 Jan 2009 16:11:27 -0000

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index