Statalist The Stata Listserver


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

Re: st: recoding variables


From   "Svend Juul" <[email protected]>
To   <[email protected]>
Subject   Re: st: recoding variables
Date   Fri, 10 Feb 2006 13:49:12 +0100

Krista wrote:

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

Austin Nichols and Nick Cox gave good solutions. I think, however, that
the following is simpler. If one of the variables is missing, risk will
be missing too.

   . generate risk = sign(tobacco-poker)
   . recode risk (-1=1)(0=3)(1=2)

For help on the sign() fuction, type
   . help sign()

Hope this helps.
Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: [email protected]
__________________________________________

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