# RE: st: RE: A query about min in stata

 From "Martin Weiss" To Subject RE: st: RE: A query about min in stata Date Fri, 22 Aug 2008 13:42:15 +0200

```Well, it calculates the endpoint of the rolling min calculation, depending
on the index "i". To make Stata calculate, you put the equal sign in front
of the mathematical expression. Not sure whether it has to be there, but I
want to err on the safe side here...

HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Ashim Kapoor
Sent: Friday, August 22, 2008 1:28 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: A query about min in stata

Hello Martin,

What is that = doing in that statement starting with " qui " doing. It
works. But why ?

Thank you,
Ashim.

On Fri, Aug 22, 2008 at 4:30 PM, Martin Weiss
<martin.weiss@uni-tuebingen.de> wrote:
> If that is supposed to be some kind of "rolling" estimation,
>
> *************
> sysuse auto , clear
> g rollingmin=.
> forv i =1/65{
> qui su mpg in `i'/`=`i'+9'
> di in red "min in `i' to `=`i'+9': " r(min) _n
> qui replace rollingmin = r(min) in `i'
> }
>
> l rollingmin
> *************
>
> HTH
> Martin
>
> -----Original Message-----
> From: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Ashim Kapoor
> Sent: Friday, August 22, 2008 12:43 PM
> To: statalist@hsphsun2.harvard.edu
> Cc: surjit.bhalla@oxusinvestments.com
> Subject: st: A query about min in stata
>
> Hello everyone,
>
> I am trying to do the following : -
>
> I have a variable r. I want to create a variable m=min( r, r[_n-1],
> ... ,r[_n-9])
>
> I guess I can use a while loop to do this but that is quite slow. An
> alternative would be to define r0=r,r1=r[_n-1],..,r9=r[_n-9]
> and then say m=rmin ( r0 r1 ... r9).
>
> My question is that is there a built in way in stata to do this ? like
> say by using egen ?
>
> Thank you all for your time and effort.
>
> Ashim. : )
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```