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" <>
To   <>
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" <>
To: <>
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.


*   For searches and help try:

© Copyright 1996–2022 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index