Statalist The Stata Listserver


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

st: RE: Re: RE: Issue with rounding


From   "Newbie" <ns.mlists@gmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Re: RE: Issue with rounding
Date   Fri, 6 Oct 2006 14:19:48 +0100

Thanks Nick and Michael for help! Michael's code did just the trick! 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Michael Blasnik
Sent: 06 October 2006 13:56
To: statalist@hsphsun2.harvard.edu
Subject: st: Re: RE: Issue with rounding

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

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