Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: gen new variable


From   Lars Korsholm <[email protected]>
To   [email protected]
Subject   Re: st: gen new variable
Date   Mon, 21 Oct 2002 13:45:42 +0200 (MEST)

something like

gen var=.
for oldval in num 2 3 ... \ newvar in num 1 6 ... : replace var=newvar if x==oldvar

Best Lars

On Mon, 21 Oct 2002, Kompal Sinha wrote:

> Hi there,
> I want to generate a new variable based on a variable x. That is the new
> variable should have value 1 if x=2, value 6 if x=3 and so on. How do I
> proceed.
> Thanks
> kompal
> 
> *
> *   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/
> 

............................................
: Lars Korsholm Ph.D.,                     :
:  Department of Statistics and Demography :
:  University of Southern Denmark          :
:  Sdr. Boulevard 23A, 1.                  :
:  DK-5000 Odense C                        :
: Phone   +45 6550 3608                    :
: Fax     +45 6595 7766                    :
: Mail    [email protected]              :
: Web     http://www.isd.sdu.dk/~korsholm  :
:..........................................:


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