Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: controlling display formats in macros


From   Eric Booth <ebooth@ppri.tamu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: controlling display formats in macros
Date   Sat, 27 Feb 2010 18:29:01 -0600

>

See -help extended_fcn-:

***
	**using auto.dta:
webuse auto, clear
rename price ln_wage
rename mpg ttl_exp
**
reg ln_wage  ttl_exp
matrix slope = e(b)
local b1:di  %4.2f slope[1,1]
twoway ///
(lfit ln_wage ttl_exp, lcolor(black) lwidth(medthick)), ///
   	 title (Wages regressed on labor force experience) ///
	 subtitle (slope = `b1')
***

~ Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
ebooth@ppri.tamu.edu
Office: +979.845.6754

On Feb 27, 2010, at 6:11 PM, Campbell, Richard T. wrote:

> For teaching purposes, I am using lfit to run some
> regression models with graphic displays. I want to
> capture the slope value and display it in the title
> for the graph. I capture the value of the slope in
> a variable and set a local macro to the value of that
> variable. I then insert the value of the macro in
> the title line as in title (slope is `slope'). This
> works nicely except that the slope value is printed to
> about 18 decimal places.
> 
> Here is the code.
> 
> reg ln_wage = ttl_exp
> matrix slope = e(b)
> gen b11 = slope[1,1]
> format b11 %4.3f
> local b1 = b11
> twoway ///
> (lfit ln_wage ttl_exp, lcolor(black) lwidth(medthick)), ///
>    	 title (Wages regressed on labor force experience) ///
> 	 subtitle (slope = `b1')
> 
> I can't attach the graph, but as I said, the value of b1
> in the subtitle (last line above) displays 18 digits. Is
> there some way to control this display format?
> 
> 
> 
> 
> 
> 
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index