Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: Accessing post-estimation variable names


From   "Jan Teorell" <[email protected]>
To   [email protected]
Subject   Re: st: RE: Accessing post-estimation variable names
Date   Wed, 8 Dec 2004 21:53:19 +0100

Fast and fabulous!

/Jan

On 8 Dec 04, at 18:16, Nick Cox wrote:

> . sysuse auto 
> 
> . reg mpg weight price length
> 
> . mat b = e(b) 
> 
> . local names : colnames b 
> 
> . di "`names'"
> weight price length _cons
> 
> In your code 
> 
> mat b = e(b) 
> local cn : colnames `b' 
> 
> you are using a local macro b, 
> which presumably was defined earlier. 
> Depending on what it contains, 
> some bizarre results would not be 
> surprising. 
> 
> In fact 
> 
> local names : colnames e(b) 
> 
> also works. You just need to ignore 
> the _cons. 
> 
> Nick 
> [email protected] 
> 
> Jan Teorell
>  
> > I am writing a program for a post-estimation command where I need 
> > to access the names of all the variables (not only the dependent 
> > one) that were used by the previous estimation command. For 
> > example, after regr y x z w, I want access to the string "y x z w" in 
> > my own command (long), parse this string and make a number of 
> > transformations on each of its variables. Anyone knows how to 
> > access the string? (I thought mat b = e(b), local cn: colnames `b' 
> > would to it, but cn contains strange series of numbers, no variables 
> > names; apparently, the macro extended function colnames only 
> > works in order to name the columns of other matrices with mat 
> > colnames.)
> 
> *
> *   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/



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