Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: AW: finding the max of a variable and then using it


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: AW: finding the max of a variable and then using it
Date   Tue, 10 Aug 2010 16:54:03 +0200

<> 

Nothing prevents you from using your -egen-erated variables, btw:


*************
sysuse auto, clear
egen maxprice=max(price)
egen minprice=min(price)
egen meanprice=mean(price)
scatter weight price, ///
xline(`=minprice' `=meanprice' `=maxprice') ///
xla(`=minprice' `=meanprice' `=maxprice')
*************

As you rightly say, these are constant. Stata just grabs the first
observation and processes it, if you refer to it via `= '...


HTH
Martin


-----Ursprüngliche Nachricht-----
Von: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Data Analytics
Corp.
Gesendet: Dienstag, 10. August 2010 16:43
An: statalist@hsphsun2.harvard.edu
Betreff: st: finding the max of a variable and then using it

Hi,

I have a data set with a variable called opp_price.  I'd like to find 
the maximum value for opp_price (I would imagine I'd use

egen opp = max(opp_price)

or something like this, but then use this single value in subsequent 
graphing statements like the following:

xline(opp, lwidth(thin))
text(0.0 238 "OPP: $opp", place(w))

Of course this doesn't work since opp is a new variable with as many 
observations as opp_price.  I need a scalar that I can then use in 
subsequent statements.  Can anyone help?

Thanks,

Walt

________________________

Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536
________________________
(V) 609-936-8999
(F) 609-936-3733
walt@dataanalyticscorp.com
www.dataanalyticscorp.com

_____________________________________________________


-- 
________________________

Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro, NJ 08536
________________________
(V) 609-936-8999
(F) 609-936-3733
walt@dataanalyticscorp.com
www.dataanalyticscorp.com

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


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