Statalist The Stata Listserver


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

Re: st: wrap lines in title (subtitle,caption) with macro names as text


From   [email protected]
To   [email protected]
Subject   Re: st: wrap lines in title (subtitle,caption) with macro names as text
Date   Tue, 20 Mar 2007 12:20:27 -0500

You can use -local macname :  piece ..- to break up long variable 
labels.  

The example below breaks the label into lines approximately 30 
characters in length.


sysuse auto, clear
label var mpg "Supercalifragilisticexpialidocious! This is a very very 
long variable label"

foreach var of varlist mpg head {
local varlab: variable label `var'
local l = length("`varlab'")
local b = ceil(`l'/30)

if `l' > 30 {
	forv i = 1/`b' {
		local lab`i': piece `i' 30 of "`varlab'", nobreak
		local varlab2 "`varlab2' "`"`lab`i''"'"  "
	}
}
else {
	local varlab2 "`varlab'"
}
scatter price `var', caption("`varlab2'") xtitle(date) name(gr_`var', 
replace)
}


Scott

----- Original Message -----
From: Christian Mackenrodt <[email protected]>
Date: Tuesday, March 20, 2007 7:38 am
Subject: st: wrap lines in title (subtitle, caption) with macro names 
as text
To: [email protected]

> Hi,
> 
> I plot scatter plots with a loop and I use the variable label as 
> caption. So far, so good. Sometimes the label is too long and I 
> have to wrap lines. But I don't know how do to it. Can anybody 
> give me a hint, please?
> 
> Best regards,
> 
> Chris
> 

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