|
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Re: saving memory local vs usual variable
loc absmax=max(`max', r(max))
at the end of your code to get this into a -local- then?
HTH
Martin
_______________________
----- Original Message -----
From: "Nick Cox" <[email protected]>
To: <[email protected]>
Sent: Friday, October 03, 2008 7:37 PM
Subject: RE: st: Re: saving memory local vs usual variable
Not the main point, perhaps, but there is a much more direct way to do
this.
sysuse auto, clear
su price, meanonly
local max = r(max)
su trunk, meanonly
di max(`max', r(max))
Nick
[email protected]
Martin Weiss
Well, -egen- does not take more than one variable because usually that
is
what users want: either the -max- of a variable or the max across
columns,
which -egen- also supports with the -rowmax- option. If you want the
maximum
of two vars for whatever reason:
sysuse auto, clear
tempvar prmax trmax overallmax
egen `prmax'=max(price)
egen `trmax'=max(trunk)
egen `overallmax'=rowmax(`prmax' `trmax')
su `overallmax',mean
loc max=r(max)
di in red `max'
Ashim Kapoor
On 2nd thought.
egen j=max(x) DOES NOT take more than one variable.
It is gen which can do the max of 2 or more variables.
So since egen returns a variable with ONE constant value, it would
seem that it should be allowed to be stored in a scalar / local macro.
*
* 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/