Svend is right.
What's more, if you have ordered codes, the -recode- is
unnecessary.
For example a mapping to codes 1 2 3 is given by 2 + sign(tobacco - poker).
Nick
[email protected]
Svend Juul
> 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()
*
* 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/