Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Tostring (string from a numerical variable)
From
Scott Merryman <[email protected]>
To
[email protected]
Subject
Re: st: Tostring (string from a numerical variable)
Date
Wed, 17 Mar 2010 11:58:12 -0500
There is no problem with negative signs. Is var_1 a large number? Compare:
clear
set obs 1
gen x = -100
tostring x, gen(strx)
clear
set obs 1
gen double x = -123456789123456
tostring x, gen(strx)
tostring x, gen(strx) format(%17.0g)
If you -set trace on- on the -tostring- that fails, you will see it
appears to default to %12.0g format - which is too small in this case:
- else {
- local fmt "%12.0g"
- local format `", "%12.0g""'
- }
Scott
On Wed, Mar 17, 2010 at 11:36 AM, carmen gamarra
<[email protected]> wrote:
>
> Hi people,
> I wanna generate a variable string from a numerical variable that has negative signe (in front of the number). Is this possible? Because Stata gives me the following message.
>
> (tostring var_1, generate( var_1str)) var_1 cannot be converted reversibly; no generate.
>
> What must I do? Thanks in advance
>
> carmen
*
* 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/