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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

To |
<statalist@hsphsun2.harvard.edu> |

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

Date |
Fri, 3 Oct 2008 19:13:48 +0200 |

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'

HTH

Martin

_______________________

----- Original Message ----- From: "Ashim Kapoor" <ashimkapoor@gmail.com>

To: <statalist@hsphsun2.harvard.edu>

Sent: Friday, October 03, 2008 6:59 PM

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

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.

Thank you,

Ashim.

On Fri, Oct 3, 2008 at 10:26 PM, Ashim Kapoor <ashimkapoor@gmail.com> wrote:

Ahh I see what you are saying. For multiple variables it won't work. I usually use it to find the max of ONE variable. I guess that confused me. Thank you, Ashim. On Fri, Oct 3, 2008 at 10:21 PM, Eva Poen <eva.poen@gmail.com> wrote:2008/10/3 Ashim Kapoor <ashimkapoor@gmail.com>:And I am still puzzled as to why someone would not allow us to set local j=max(list) cos that seems intuitive.If the list includes variable names, how is Stata supposed to know which observation's maximum you mean? -egen- is meant to work with variables. -egen- functions are not available outside -egen. On the other hand, there are Stata functions (-help functions-) which will work in general expressions. Therefore, local j = max(4, 92, -35, 399, 0) will correctly store 399 in local macro j. Eva * * 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/

**Follow-Ups**:**RE: st: Re: saving memory local vs usual variable***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: saving memory local vs usual variable***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**st: Re: saving memory local vs usual variable***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: st: Re: saving memory local vs usual variable***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**Re: st: Re: saving memory local vs usual variable***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: st: Re: saving memory local vs usual variable***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**Re: st: Re: saving memory local vs usual variable***From:*"Eva Poen" <eva.poen@gmail.com>

**Re: st: Re: saving memory local vs usual variable***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**Re: st: Re: saving memory local vs usual variable***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

- Prev by Date:
**Re: st: corr_svy & covariance matrix for survey data** - Next by Date:
**Re: st: impact of bootstrapping on predicted probabilities of logistic regression models** - Previous by thread:
**Re: st: Re: saving memory local vs usual variable** - Next by thread:
**RE: st: Re: saving memory local vs usual variable** - Index(es):

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