Statalist


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

st: R: Changing neg into pos values


From   "Carlo Lazzaro" <[email protected]>
To   <[email protected]>
Subject   st: R: Changing neg into pos values
Date   Mon, 25 Feb 2008 09:11:45 +0100

Dear Ziad,

you may try this:
*****************begin example********************
set obs 10
obs was 0, now 10

g var1=5 in 1/5
(5 missing values generated)

replace var1=-4 in 6/10
(5 real changes made)

g var2=100-var1 if var1>0
(5 missing values generated)

replace var2=100-var1 if var1<0
(5 real changes made)
*********************end example***********************

HTH and Kind Regards,

Carlo
-----Messaggio originale-----
Da: [email protected]
[mailto:[email protected]] Per conto di Ziad El-Khatib
Inviato: luned� 25 febbraio 2008 8.51
A: [email protected]
Oggetto: st: Changing neg into pos values

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/



*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index