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

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 

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', 


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

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

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