Statalist


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

Re: st: Changing neg into pos values


From   "krishanu karmakar" <krishkarmakar@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Changing neg into pos values
Date   Mon, 25 Feb 2008 13:52:56 +0530

You may just use

generate var2=100-var1

when var1 >0 this will give a value<100 as you want
when var2<0 this will give a value>100 as you want

Krishanu

On 2/25/08, Ziad El-Khatib <Ziad.El-Khatib@ki.se> wrote:
> Dear STATAlister,
> i have variable var1 containing both of pos or neg values, i want to
> create new variable var2 equal to var1:
>  to have var2=100-var1 if var1 >0
>  to have var2=100 plus the positive value of var1 if var1<0 (for
> example if var1= -4 then var2 would be = 100 + 4 = 104
>
> any tips?
>
>
> Thank you in advance and best regards
> ziad
> *
> *   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/
>


-- 
Read it: http://www.stata.com/support/faqs/res/statalist.html
Specially Question 3.
*
*   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/



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