Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: using the max command


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: using the max command
Date   Wed, 4 Feb 2004 11:16:10 -0500

you don't need to create a whole variable just to hold one number, try:

sum var5, meanonly
local max=r(max)
forval i=1/`max' {...

Michael Blasnik
[email protected]


----- Original Message ----- 
From: "Amit Khandelwal" <[email protected]>
To: <[email protected]>
Sent: Wednesday, February 04, 2004 10:57 AM
Subject: st: using the max command


> I have a variable for which I need the maximum element. So, I typed:
>
> egen element=max(var5)
>
> Now, I need to use this value in a for-loop
>
> foreach i=1(1)element {
> ...
> }
>
> but that didn't work. So, then I tried
>
> foreach i=1(1)element[1] {
> ...
> }
>
> to try to pick off the first element of the vector, but that didn't work,
> either.
>
> Thanks,
> Amit
>
>
>
>
> *
> *   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index