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/