Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Getting all independent vars from a set of reg equations |

Date |
Mon, 27 Jun 2011 10:46:55 +0100 |

You did not show any of your code, but are presumably doing something like this indeplist local x = r(X) when the latter line should be indeplist local x `r(X)' See also SJ-8-4 pr0045 . . . . . . . . Stata tip 70: Beware the evaluating equal sign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q4/08 SJ 8(4):586--587 (no commands) tip explaining the pitfall of losing content in a macro because of limits on the length of string expressions I don't understand your second question. -drop y*- is perfectly legal. When you say drop do you mean omit? Nick On Mon, Jun 27, 2011 at 10:08 AM, Narahari H.S. <naraharihs@yahoo.co.in> wrote: > Thanks for the example code and the explanation. It works like a charm :). > > However, I have a large number of independent variables and their total no. of characters exceeds 244 - thus resulting in a truncation. How do I tackle this? > > Also, among the independent variables, I have dummy variables for years which are named with a "y" prefix (like y2000, y2005 etc.). Is there any way to drop these variables? (I was hoping for a -drop y*- command similar to -list uniq- but thats not available) > > Warm Regards > Hari > > > > --- On Sun, 26/6/11, Maarten Buis <maartenlbuis@gmail.com> wrote: > > From: Maarten Buis <maartenlbuis@gmail.com> > Subject: Re: st: Getting all independent vars from a set of reg equations > To: statalist@hsphsun2.harvard.edu > Date: Sunday, 26 June, 2011, 9:20 PM > > On Sat, Jun 25, 2011 at 3:45 PM, Narahari H.S. wrote: >> I have to present a correlation matrix of all independent variables from a set of regression equations. I thought that if I could list (in one place) all the independent variables from all the equations, I could use them with the pwcorr command. > > You can get the independent variables of one regression model using > -indeplist- (which is available form SSC). If you have multiple > models, you need to know some tricks on how to deal with local macros > in Stata. Below is an example with three models. First I stack all the > names in one local macro `x', and than I drop the duplicate names > using -local x: list uniq x-. > > *---------------- begin example ----------------------- > sysuse auto > > reg price mpg foreign > indeplist > local x = r(X) > > reg price mpg rep78 foreign > indeplist > local x "`x' `r(X)'" > > reg price mpg rep78 foreign gear_ratio > indeplist > local x "`x' `r(X)'" > > di "`x'" > > local x : list uniq x > di "`x'" > > cor `x' > *------------------ end example ---------------------- > (For more on examples I sent to the Statalist see: > http://www.maartenbuis.nl/example_faq ) > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**Re: st: Getting all independent vars from a set of reg equations***From:*"Narahari H.S." <naraharihs@yahoo.co.in>

**References**:**Re: st: Getting all independent vars from a set of reg equations***From:*"Narahari H.S." <naraharihs@yahoo.co.in>

- Prev by Date:
**Re: st: Getting all independent vars from a set of reg equations** - Next by Date:
**Re: st: problems with "set statatmp"** - Previous by thread:
**Re: st: Getting all independent vars from a set of reg equations** - Next by thread:
**Re: st: Getting all independent vars from a set of reg equations** - Index(es):