[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
Friedrich Huebler <huebler@rocketmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: Re: Rounding problem in graph |

Date |
Fri, 12 Sep 2003 07:10:56 -0700 (PDT) |

Nick, Thank you for your enlightening reply. My problem was that the number 74.90000000000001 was drawn in a graph, instead of 74.9. Converting the variable to a string is the solution I needed. I also appreciate the style advice, I was not aware of the illegal syntax and I had not considered that I could use the values returned by -summarize- to create macros. With your help I could reduce my data set from sex rg5 order tmax mmax fmax Male 72.2 2 74.9 72.2 74.9 Female 74.9 1 74.9 72.2 74.9 to sex rg5 order Male 72.2 2 Female 74.9 1 "Male" and "Female" are labels for the actual values 1 and 2. My original (and incorrect) commands for producing a bar graph were: #delimit ; local textpos1 = tmax/100*20; local textpos2 = tmax/100*50; local mvalue = round(mmax,.1); local fvalue = round(fmax,.1); graph bar rg5, over(sex, sort(order) gap(0) axis(off)) bar(1, bcolor(0 153 255) blcolor(white)) yscale(r(0 `max(tmax)') off) ylabel(minmax, nogrid) outergap(0) plotr(m(zero)) graphregion(color(white) margin(zero)) text(`textpos1' 25 "Girls", size(20) color(white)) text(`textpos1' 75 "Boys", size(20) color(white)) text(`textpos2' 25 "`fvalue'%", size(20) color(white)) text(`textpos2' 75 "`mvalue'%", size(20) color(white)) legend(off); The revised commands are: #delimit ; sum rg5; local scalemax = r(max); local textpos1 = r(max)/100*20; local textpos2 = r(max)/100*50; sum rg5 if sex==1; local mvalue = string(r(max), "%2.1f"); sum rg5 if sex==2; local fvalue = string(r(max), "%2.1f"); graph bar rg5, over(sex, sort(order) gap(0) axis(off)) bar(1, bcolor(0 153 255) blcolor(white)) yscale(r(0 `scalemax') off) ylabel(minmax, nogrid) outergap(0) plotr(m(zero)) graphregion(color(white) margin(zero)) text(`textpos1' 25 "Girls", size(20) color(white)) text(`textpos1' 75 "Boys", size(20) color(white)) text(`textpos2' 25 "`fvalue'%", size(20) color(white)) text(`textpos2' 75 "`mvalue'%", size(20) color(white)) legend(off); Thanks again, this was a most instructive excercise. Friedrich Huebler __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com * * 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/

**Follow-Ups**:**st: RE: Re: Rounding problem in graph***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**References**:**st: RE: Rounding problem in graph***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

- Prev by Date:
**st: describe** - Next by Date:
**st: RE: Re: Rounding problem in graph** - Previous by thread:
**st: RE: Rounding problem in graph** - Next by thread:
**st: RE: Re: Rounding problem in graph** - Index(es):

© Copyright 1996–2021 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |