If you want to change all values of suzy for values of scott that are
positive and not missing then you can use this command:
replace suzy = -suzy if suzy>0 & scott>0 & scott<.
Friedrich Huebler
--- Suzy <scott_788@wowway.com> wrote:
> Dear Martin,
>
> Your code worked perfectly well for my data... Thanks!! Thanks
> also to
> Nick!
>
> replace suzy = -suzy if suzy > 0 & ( scott > 0 & scott < 103)
> (the max
> value was 102.27272)
>
>
> Maarten buis wrote:
>
> >Lets call this other variable which captures the common
> charecteristics scott, and suzy has to be
> >negative if scott is larger than 2 and less than pi or is equal to
> e to the power pi. Than you
> >would code:
> >
> >replace suzy = -suzy if suzy > 0 & ( scott > 2 & scott < c(pi) ) |
> scott == exp(1)^c(pi)
> >
> >--- Suzy <scott_788@wowway.com> wrote:
> >
> >
> >
> >>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
> >>>n.j.cox@durham.ac.uk
> >>>
> >>>Suzy
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>>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:
> >>>* http://www.stata.com/support/faqs/res/findit.html
> >>>* http://www.stata.com/support/statalist/faq
> >>>* http://www.ats.ucla.edu/stat/stata/
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>*
> >>* 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/
> >>
> >>
> >>
> >
> >
> >-----------------------------------------
> >Maarten L. Buis
> >Department of Social Research Methodology
> >Vrije Universiteit Amsterdam
> >Boelelaan 1081
> >1081 HV Amsterdam
> >The Netherlands
> >
> >visiting adress:
> >Buitenveldertselaan 3 (Metropolitan), room Z214
> >
> >+31 20 5986715
> >
> >http://home.fsw.vu.nl/m.buis/
> >-----------------------------------------
> >
> >
> >
> >___________________________________________________________
> >Switch an email account to Yahoo! Mail, you could win FIFA World
> Cup tickets. http://uk.mail.yahoo.com
> >*
> >* 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/
> >
> >
> >
> >
> >
>
>
> *
> * 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/
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
*
* 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/