[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: RE: RE: Can you get sign of value only?
Thanks to all who responded. On the way home, thought of this:
replace x = x * (y / abs(y))
I see that there are multiple ways of doing it. Despite the fact that
I stupidly asked a question which it turns out is answered in the
"functions" help (never occurred to me it would be a function, and
quick Google search turned up nothing... sorry... long day), I
learned something from everyone's responses.
--
Danielle H Ferry
On Mar 23, 2006, at 6:27 PM, Nick Cox wrote:
Note that the difference between this and using -sign(y)-
is that -sign(0)- is 0.
A quite different point is that there is another way
to write what Jennifer is suggesting, namely
gen z = cond(y < 0, -x, x)
Nick
[email protected]
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/