Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: RE: controlling display formats in macros


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: RE: controlling display formats in macros
Date   Sun, 28 Feb 2010 10:33:39 +0100

<>

You can dispense with the -macro- completely:


*******
sysuse nlsw88, clear

gen ln_wage=log(wage)
reg ln_wage ttl_exp

tw (lfit ln_wage ttl_exp, lcolor(black) lwidth(medthick)), ///
title (Wages regressed on labor force experience) /// 
subtitle (slope = `=string(_b[ttl_exp], "%4.3f")')
*******

This requires you to execute the -twoway- while the -regress- returned
values are still around.

BTW, why is there an equal sign in your -reg ln_wage = ttl_exp-? I bet that
ends up in an "invalid syntax" error...


HTH
Martin

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Campbell, Richard
T.
Sent: Sonntag, 28. Februar 2010 01:11
To: [email protected]
Subject: st: controlling display formats in macros

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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index