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

st: twoway by_option subtitle formatting


From   Roger Harbord <[email protected]>
To   Statalist <[email protected]>
Subject   st: twoway by_option subtitle formatting
Date   Sat, 07 Aug 2004 10:36:28 +0100

How can I persuade -graph twoway-'s -by- option to respect the formatting of the by-variable?

An example :

. sysuse auto
(1978 Automobile Data)

. describe gear_ratio

storage display value
variable name type format label variable label
------------------------------------------------------------
gear_ratio float %6.2f Gear Ratio

. twoway scatter price mpg if gear_ratio <2.5, by(gear_ratio )

The first subgraph's subtitle is not "2.19" as i'd expect but "2.190000057220459". The fact that gear_ratio has format %6.2f is being ignored. One work-around is to convert it to a string:

. gen gear_ratio_str = string(gear_ratio, "%6.2f")
. twoway scatter price mpg if gear_ratio <2.6, by(gear_ratio_str )

However in general the stringed version of a number will have a different sort order so the ordering of the subgraphs may not be what i want - doesn't affect this example but does in my real application. The only solution I can think of is to label each value with its value - considerable extra hassle. Is there a simpler way?

(I'm using Stata 8.2 for Windows, updated to 27 Jul 2004.)

Thanks,
Roger.
----------------------------------------------------
Roger Harbord mailto:[email protected]
Department of Social Medicine, University of Bristol

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