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: Importing a variable from another STATA file and an "xtregar" question

From   Joerg Luedicke <>
Subject   Re: st: Importing a variable from another STATA file and an "xtregar" question
Date   Tue, 7 Jun 2011 11:18:56 -0400

On Tue, Jun 7, 2011 at 10:45 AM, Jason Hecht <> wrote:
> Any help with the following questions would be greatly appreciated:
> 1.  I created a smaller panel STATA datafile from a larger panel
> datafile by discarding unneeded variables.  I now want to bring in a
> single variable from the larger datafile into the smaller panel
> datafile.  Is there an easy way to do this.

At the point you are, you probably need to merge it back in (see -help
merge-). Better would have been if you had written the code that
produces your reduced data set as part of your do-file. In that case,
you could simply go back to that section in your do-file, add the
variable name, and run the do-file again.

> 2.  I am running the following model:
> xtregar capexppenet salesppenet if totalassets>1000, re rhotype(theil) twostep
> However, instead of using "totalassets>1000,"  I now want to run the
> model on the upper 5% of the distribution of total assets.
> Is there an easy way to do this in the above model estimation code?

One possibility would be to summarize "totalassets" and then either
put in the saved results directly:

sum totalassets, d

xtregar capexppenet salesppenet if totalassets> r(p95), re
rhotype(theil) twostep

or you could save the summarize result in a scalar, for example:

sum totalassets, d
scalar assets_p95=r(p95)
xtregar capexppenet salesppenet if totalassets>assets_p95, re
rhotype(theil) twostep

which would be useful if you want to use it again with other stuff
being done in-between.

(All of that is assuming there are no missing values in "totalassets".
If there are MVs, just take that into account, too))


*   For searches and help try:

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