Bookmark and Share

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

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

Re: st: -svmat- with matrix colnames based on factor variable names?

From   Scott Merryman <>
Subject   Re: st: -svmat- with matrix colnames based on factor variable names?
Date   Sat, 12 Feb 2011 20:46:38 -0600

On Sat, Feb 12, 2011 at 4:49 AM,  <> wrote:
> The workaround I was seeking was a quick/easy/automated way of going
> from what is shown as the contents of r(c) after -matnames- to a list of
> valid variable names that preserves the essential information. The new
> list can be used to re-label the matrix prior to -svmat-. The new names
> could be based, for instance, on the old ones but drop the ":" and "."
> from the elements of r(c), and add some prefix ("_", say) to each of the
> elements. My efforts using -subinstr- and also regular expression
> functions were not productive, but that is probably a comment on my
> skills.

Something like this?

webuse nhanes2f
logit diabetes i.hsizgp i.female age i.female#c.age, nolog

margins , at(female = 1  age = 40 hsizgp = (1(1)5) )
mat at = r(at)
matnames at
local a = r(c)
foreach l of local a {
	_ms_parse_parts `l'
	local names = "`names' `=r(name)'_`r(level)' "
matrix colnames at = `names'
mat list at
svmat at, names(col)

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index