Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: RE: RE: Tostring (string from a numerical variable)


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
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 
n.j.cox@durham.ac.uk 

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index