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

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

From   "Martin Weiss" <>
To   <>
Subject   Re: st: Re: saving memory local vs usual variable
Date   Fri, 3 Oct 2008 19:57:13 +0200

loc absmax=max(`max', r(max))
at the end of your code to get this into a -local- then?

Martin _______________________
----- Original Message ----- From: "Nick Cox" <>
To: <>
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
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
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:

*   For searches and help try:

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