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]
st: RE: RE: Tostring (string from a numerical variable)
From
"Nick Cox" <[email protected]>
To
<[email protected]>
Subject
st: RE: RE: Tostring (string from a numerical variable)
Date
Wed, 17 Mar 2010 16:55:10 -0000
I don't support Martin's advice, although the help does flag it as one possibility.
Carmen's need is rather to focus on why you get this error message.
Carmen's real problem must be other than stated. Negative signs can be mapped to "-" characters without loss of information.
The most likely problem is that the variable has a fractional part that would not be preserved exactly under -real(string())-. That's the key idea of -tostring- and is what distinguishes it from the testosterone-driven brute force application of -string()-.
If that's true, the question is why is converting that to string being considered.
If that's not true, or even if it is, more information about the data is needed to give better advice.
Nick
[email protected]
Martin Weiss
Use the -force- option, risking information loss. Although negative numbers
as such do not seem to pose much of a problem for my Stata 11:
*************
clear*
inp x
-1
-2
0
3
4
5
end
tostring x, generate(strx)
l
*************
carmen gamarra [edited]
I want to generate a variable string from a numerical variable that has
negative sign (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?
*
* 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/