Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: RE: Issue with rounding


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: RE: Issue with rounding
Date   Fri, 06 Oct 2006 08:55:41 -0400

...
I think they want to know when a variable becomes constant for the remaining observations within a group, even if it is not constant for the whole group. If that is correct, then they might try:

gsort id -date
by id: gen sameaslast=sum(var==var[1])==_n

Which should flag observations which are the same as all of the remaining observations within a given id.

Michael Blasnik

----- Original Message ----- From: "Nick Cox" <n.j.cox@durham.ac.uk>
To: <statalist@hsphsun2.harvard.edu>
Sent: Friday, October 06, 2006 7:42 AM
Subject: st: RE: Issue with rounding



The way to solve these problems is to avoid them.
Your problem is to check something, not to
calculate something.

The most direct way to see whether values of
-some- variable remain constant in groups of
-block- is

bysort block (some) : assert some[1] == some[_N]

If there is any difference between values, this
will show up as a difference between the first (smallest)
and the last (largest). Conversely, if all values are
the same, the first and last will also be the same.

Nick
n.j.cox@durham.ac.uk

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index