Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: transforming observations |
Date | Tue, 21 Feb 2012 14:54:36 +0000 |
Your example is a little fuzzy. What is it that you already have, x or temp or both? But you can create a new variable like this gen x = cond(temp <= 0, 0, cond(temp == 30, 1, temp)) To do this for several variables use a -foreach- loop. Nick On Tue, Feb 21, 2012 at 2:46 PM, Mintewab Bezabih <Mintewab.Bezabih@economics.gu.se> wrote: > I need to transform observations in my dataset (3476 obervations by 40 variables) into categorical variables based on the following set of rules : > > observation x=0 if temp<=0 > observation x=1 if temp==30 > observation x=x if temp>=31 > > As you could imagine it would take me ages to do that one by one. Is there a compact way of doing this? > > Many thanks in advance > minti > * > * 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/ * * 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/