Statalist


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

st: Conditional stack


From   HSIUTZU CHANG <[email protected]>
To   [email protected]
Subject   st: Conditional stack
Date   Thu, 30 Jul 2009 14:50:01 -0400

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/



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