title("fitted line: y = `=trim("`:di %7.2f `=_coef[_cons]''")' + `=trim(`:di %7.2f `=_coef[x]'')' * x")
`=_coef[_cons]' is the constant
`=_coef[x]' is the x coefficient
`:di %7.2f XXX' formats XXX as %7.2f
`=trim(" YYY ")' removes blanks from ends of YYY
Thomas J. Steichen
[email protected]
----------------------------------------------------------------------------
Facts do not cease to exist because they are ignored. - Aldous Huxley
----------------------------------------------------------------------------
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> Reardon, Sean F.
> Sent: Tuesday, January 18, 2005 2:08 PM
> To: [email protected]
> Subject: st: changing display format of macro contents
>
>
> i want to fit and draw a regression line and label the line,
> like this:
>
> reg y x
> matrix coefs=e(b)
> loc beta1hat=coefs[1,1]
> loc beta0hat=coefs[1,2]
>
> lfit y x, title("fitted line: y = `beta0hat' + `beta1hat' * x")
>
> when i do this, i get values for the estimated coefficients
> displayed with far more precision than i want. so i want to
> display only, say, 2 digits after the decimal for each macro.
> i wasn't able to figure out a way to apply a display format
> to a macro, so i tried adding this code before the -lfit- command:
>
> loc beta1hat = int(`beta1hat'*100+0.5)/100
> loc beta0hat = int(`beta0hat'*100+0.5)/100
>
> this works most of the time, but sometimes i get a graph that
> has a title like this:
>
> "y = 7.84000000001 + 2.31 * x"
>
> or
>
> "y = 7.83999999999 + 2.31 * x"
>
> i assume that the problem is the rounding doesn't work in
> binary all the time. can anyone suggest a way around this?
> (obviously if i were making a single graph, i could put the
> coefficients in the title by hand, but this code is part of a
> larger program, so i'd like it
> automated.)
>
> thanks,
> sean.
> _____________________________
>
> please note new contact information: _____________________________
>
> sean f. reardon
> associate professor of education and (by courtesy) sociology
> school of education 485 lasuen mall, #315 stanford university
> stanford, ca 94305-3096 650.736.8517 (office phone)
> 650.725.7412 (office fax) [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/
>
-----------------------------------------
CONFIDENTIALITY NOTE: This e-mail message, including any attachment(s),
contains information that may be confidential, protected by the attorney-
client or other legal privileges, and/or proprietary non-public
information. If you are not an intended recipient of this message or an
authorized assistant to an intended recipient, please notify the sender by
replying to this message and then delete it from your system. Use,
dissemination, distribution, or reproduction of this message and/or any of
its attachments (if any) by unintended recipients is not authorized and
may be unlawful.
*
* 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/