Statalist The Stata Listserver


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

Re: st: conceptual question regarding -egen-


From   Austin Nichols <[email protected]>
To   [email protected]
Subject   Re: st: conceptual question regarding -egen-
Date   Mon, 6 Feb 2006 13:58:32 -0500

su p_pred_mort, meanonly
scalar maxpred=r(max)
su p_act_mort, meanonly
scalar maxmax = max(maxpred,r(max))
di maxmax

See -help return- for more or type -return list- and -eret li- after
all of your favorite commands to see what is available.  Also try
-cret li- sometime.

On 2/6/06, daniel waxman <[email protected]> wrote:
> If one performs -egen- across the entire dataset rather than -,by()- then it
> returns what is essentially the same scalar for every observation.
>
> Is there any way to actually generate a scalar rather than a variable?
> For example, I am interested in having a scalar or local macro which
> contains the largest value of either of two variables
>
> i.e.
>
> . egen maxmort = max(p_pred_mort)
> . egen predmort = max(p_act_mort)
>
> . local maxmax = max(maxmort, predmort)
> . drop maxmort predmort
>
> I know that bytes are cheap these days, but it seems odd that I have to
> generate 100,000 of each of these values when I only need one.  Or do I have
> major conceptual issues?
>
>
> *
> *   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