Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Replace function


From   Christian Westby <[email protected]>
To   [email protected]
Subject   st: Replace function
Date   Wed, 20 Jun 2012 10:59:05 -0500

Dear Statalisters,

I have a quick question that I cannot seem to find an answer to.

I want to replace the values of a variable only in a specified subset
of observations

For example:

set obs 10
gen id=_n
expand 3
gen sex=0
replace sex=1 if id== 1 3 4 7 9 (I only want to replace the value for
these specific id’s)

The above replace statement does not work. Beside inputting the data
by hand,  how could I get this to work? I have tried adding the “in”
function such as

replace sex=1 if id in(1 3 4 7 9)

but it too did not work.


Regards

-Chris

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index