Statalist The Stata Listserver

[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Changing positive values to negative in Stata

From   Suzy <[email protected]>
To   [email protected]
Subject   Re: st: RE: Changing positive values to negative in Stata
Date   Thu, 20 Apr 2006 16:55:08 -0400

Thanks Nick - I neglected to state that have over 600 observations with all different positive values (as well as negative values and missing values) within the subgroup of total observations of the variable, so this code could be somewhat inefficient. Also, it is difficult to specify which observations, for example, by id - thus the next best thing in this instance seems to be to sort by their common characteristic - which is captured by another variable.

Nick Cox wrote:

replace suzy = -suzy if suzy > 0 & <whatever>
So if suzy is positive, it is negated. The crunch is specifying the extra condition <whatever> that catches just the observations desired.
Sorting is a red herring here. So long as you can specify which observations you want, sort order
is immaterial.
Nick [email protected]

I have a continuous variable with positive, negative, and zero values and also missing values(.). I would like to know if anyone has an easy Stata code/command to change just the positive values to a negative (change the sign: 4.4567 to -4.4567) for just a particular subgroup of the total (n=661 out of over N=4,000). Within this subgroup (which I can sort, but not by id) there already are a few appropriately negative values in place.

* For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index