Statalist The Stata Listserver


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

RE: st: conceptual question regarding -egen-


From   "daniel waxman" <[email protected]>
To   <[email protected]>
Subject   RE: st: conceptual question regarding -egen-
Date   Tue, 7 Feb 2006 02:31:25 -0500

Thanks much for the reply.  There is much to learn...

Anyway, I'd imagine that there is little difference in overhead between
using -sum- in this way and creating and then dropping a temporary variable.
I should get over the frugality issues.


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Austin Nichols
Sent: Monday, February 06, 2006 1:59 PM
To: [email protected]
Subject: Re: st: conceptual question regarding -egen-

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/


*
*   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