Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: Query: Adding yline()


From   [email protected]
To   [email protected]
Subject   st: RE: RE: Query: Adding yline()
Date   Mon, 18 Aug 2003 19:08:58 +0200

My great thanks for the advice, I will definitely use the first method
suggested.


Amani

-----Original Message-----
From: Nick Cox [mailto:[email protected]]
Sent: Monday, 18 August 2003 18:44
To: [email protected]
Subject: st: RE: Query: Adding yline()


[email protected]
> 
> I need help with adding a yline to a graph - the value of 
> the yline comes
> from a variable "med1" as follows
> 
> egen med1=median(midobs1)
> 
> graph box midobs1 rmidobs1, over(site) yline(`med1') 
> 
> The graph command runs but does not show the required yline().
> 
> I would very much appreciate your suggestions.

This doesn't work for the following reason. 

`med1' says get the local macro -med1- and 
put its contents _here_. 

Evidently you never defined such a local macro, 
so there is no reason to expect it to work. 

This should work: 

su midobs1, detail 
graph box midobs1 rmidobs1, over(site) yline(`r(p50)') 

Note that there is no need to create a variable 
containing a constant again and again. 

However, 

egen med1 = median(midobs1) 
graph box midobs1 rmidobs1, over(site) yline(`=med1[1]') 

would also work. 

`=med1[1]' says work out -med1[1]- and put its value _here_. 
As by construction all the values of -med1- are the same, 
we could pick any one of them. 

As said, this will work, but I suggest that the first
method is better. 

Nick 
[email protected] 

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