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

st: operation on group


From   Radu Ban <[email protected]>
To   <[email protected]>
Subject   st: operation on group
Date   Sat, 10 May 2003 18:24:28 -0400 (EDT)

dear all,

i have a dataset in which a variable has to be the same within groups
created by other variables. the variable is a 0-1 binary. if, within a
group there's at least one 0 zero value i want to set all the values to 0.
the groups are generated by the "serial" and "month" variables.

i used the following command:

bysort serial month: replace var = 0 if (var ~= var[_n-1] & _n>1) |
(var ~= var[_n+1] & _n==1)

but this appears to be causing some randomness because the end results of
the code are different with each re-run. and i don't see other commands
that might cause randomness.

thanks in advance,

radu ban





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