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

st: RE: twoway by_option subtitle formatting


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: twoway by_option subtitle formatting
Date   Sat, 7 Aug 2004 16:02:09 +0100

One work-around would be something like 

egen group = group(gear_ratio), label 

and 

_crcslbl group gear_ratio 

or 

label var group `"`: variable label gear_ratio'"' 

and then use -group- for the -by()-. 

Nick 
[email protected] 

Roger Harbord
 
> 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.)

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