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