Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Conditional stack


From   PEREZ PEREZ JORGE EDUARDO <[email protected]>
To   "[email protected]" <[email protected]>
Subject   st: RE: Conditional stack
Date   Thu, 30 Jul 2009 19:27:09 +0000

gen vnew=.
replace vnew=v2x if v1=="x"
replace vnew=v2y if v1=="y"

I don't know if there's a single command that does this, though.
_________________________
Jorge Eduardo Pérez Pérez

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of HSIUTZU CHANG
Sent: jueves, 30 de julio de 2009 01:50 p.m.
To: [email protected]
Subject: st: Conditional stack

Dear Statalist users,

I want to generate a new variable
Vnew= V2, but using V2x or V2y will depend on the value of V1

Vnew =V2x if V1=x
Vnew =V2y if V1=y

ID      V1      V2x     V2y     Vnew
1       x       6       12      6
2       x       7       13      7
3       x       8       14      8
4       y       9       15      15
5       y       10      16      16
6       y       11      17      17

What is the command I should use if I want the result of Vnew look
like the above table?
Thanks

Betty
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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