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

RE: st: Re: saving memory local vs usual variable

From   "Nick Cox" <>
To   <>
Subject   RE: st: Re: saving memory local vs usual variable
Date   Fri, 3 Oct 2008 18:37:32 +0100

Not the main point, perhaps, but there is a much more direct way to do

sysuse auto, clear 
su price, meanonly 
local max = r(max) 
su trunk, meanonly 
di max(`max', r(max)) 


Martin Weiss

Well, -egen- does not take more than one variable because usually that
what users want: either the -max- of a variable or the max across
which -egen- also supports with the -rowmax- option. If you want the
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:

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