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

st: RE: gen newvar satisfying two conditions

From   "Martin Weiss" <>
To   <>
Subject   st: RE: gen newvar satisfying two conditions
Date   Thu, 18 Dec 2008 10:44:05 +0100

Line for the server...

For the first step, try -encode-. The third one sounds like -recode- to

Of course you could also just

gen byte hadsx= plannedsx==1 & emergsx==1

after -encode-ing...


-----Original Message-----
[] On Behalf Of b. water
Sent: Thursday, December 18, 2008 10:24 AM
Subject: st: gen newvar satisfying two conditions

dear all,
stata 8.2, windows xp pro,
i have two variables: plannedsx (for previous planned surgery) and emergsx
(for previous emergency surgery), each is answered either yes or no
(strings). i want to generate a new variable hadsx (i.e. has had surgery
previously whether as a cold procedure or an emergent one, also a yes or
no). an approach i could use (but haven't tried yet - but i think is do-ably
with minimal pain):
first: generate and replace yes or no for each variable with 0 (for no) and
1 (for yes)
second: generate a temporary variable tempvar consisting the sum of those
two variables, which therefore would only contain only values from 0, 1 or
third: generate and replace 0 with a "no" and anything>0 with a "yes"
i am wondering whether there is a more direct method to achieve what i
wanted. would appreciate advice/help in this data management matter. 
thank you,

Suspicious message? There's an alert for that. Get your HotmailR account
Send e-mail faster without improving your typing skills.
*   For searches and help try:

*   For searches and help try:

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