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 
 
"Martin Weiss" <[email protected]> 
To 
 
<[email protected]> 
Subject 
 
RE: st: Tostring (string from a numerical variable) 
Date 
 
Wed, 17 Mar 2010 18:02:50 +0100 
<>
But the connection to the "-" sign is simply not there. Your code with a
positive large number causes the exact same effects:
*************
clear
set obs 1
gen double x = 123456789123456
tostring x, gen(strx)
tostring x, gen(strx) format(%17.0g)
*************
HTH
Martin
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Scott Merryman
Sent: Mittwoch, 17. März 2010 17:58
To: [email protected]
Subject: Re: st: Tostring (string from a numerical variable)
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/
*
*   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/