Statalist The Stata Listserver


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

RE: st: recoding variables


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: recoding variables
Date   Thu, 9 Feb 2006 21:54:29 -0000

Austin's solution is fine. Just for reference an alternative is

cond(tob < pok, 1, cond(tob > pok, 2, 3)) if !mi(tob, pok) 

but I judge Austin's solution to be more direct. 

A different issue is why are you coding < == > as 1 3 2 
not 1 2 3 or 3 2 1? 

Nick 
[email protected] 

Austin Nichols
 
> g risk=(tob<pok)+2*(tob>pok)+3*(tob==pok) if !mi(tob,pok)
 
Krista Richard 

> > I'm new to stata and I need help to recode two variables 
> into one. I'm not
> > succeeding so I'm hoping someone will be able to help me out.
> >
> > I have two variables:
> >
> > age at first poker use (poker) and age of first tobacco use 
> (tobacco).
> >
> > I want to create a variable (risk_behaviour) with 3 levels 
> that will have
> > the value labels of 1 = tobacco<poker, 2 = tobacco>poker, and 3
> > tobacco=poker.  I run into trouble with this as stata is treating my
> > missing values when it calculates it and I can't seem to make it not
> > compute this when either original variable has missing values.

*
*   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