Thanks David.
This solution is to label a variable. What if you want to save as a macro?
I try your suggestion but it returns missing.
In fact, I want to put the label in a local macro. I am doing something like
this:
prog mytab
...
qui tabstat `varlist' [`weight' `exp'], stats(mean) long save
mat M=r(StatTot)
local matvar "National"
foreach i in urban region sex marstat {
cap confirm numeric `i'
qui {
lab li `i'
local min = r(min) /*To get the minimum value*/
local max=r(max) /*To get the maximum value*/
}
qui tabstat `varlist' [`weight' `exp'], stats(mean) by(`i') long save
forval j=`min'/`max' {
local lab`j': label `i' `j'
local matvar "`matvar' `lab`j''"
mat M= M \r(Stat`i')
}
}
}
mat M = M'
local matvar: list uniq matvar
mat colnames M = `matvar'
mat li M, f(%4.3f)
end
I am getting conformability error because the labels have blanks.
Best regards.
"David Harrison"
<[email protected]> To: <[email protected]>
Sent by: cc:
owner-statalist@hsphsun2. Subject: st: RE: Triming labels.
harvard.edu
11/12/2004 11:20 AM
Please respond to
statalist
-trim()- only removes leading and trailing blanks. To remove embedded blanks you
will need to use something like -subinstr()-.
Are you talking about variable labels or value labels? If variable labels, then
something along the lines of
foreach v of varlist _all {
label var `v' "`=subinstr("`: var lab `v''"," ","",.)'"
}
should remove all embedded blanks from all variable labels (which may be a
little overkill!) - to limit to certain variables change the -_all- to the
varlist you want changed.
Something along similar lines ought to work for value labels.
David
[email protected]
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: 12 November 2004 16:10
To: [email protected]
Subject: st: Triming labels.
Hi,
How to remove blanks in labels (for example : "Region\ South" to
"Region\South")?
I am trying trim but it is not working.
Best regards.
Amadou.
*
* 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/
*
* 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/
*
* 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/