Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: running regressions on only certain sections of the data


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: running regressions on only certain sections of the data
Date   Mon, 19 Feb 2007 11:56:01 -0500

Maarten said

I am assuming that you have a variable called section,
which contains the strings A, B, or C.
to do the regression you requested you would type:
reg y x if section == "A"
reg y x if section == "A" | section == "C"
reg y x if section == "A" | section == "B"

For more info see: - help if- and -help operator-



If you have many sections (but need no more than 10, categorized by a string variable) you could also do

reg y x if inlist(section,"A","C")
reg y x if inlist(section,"A","B")
...

help functions -> programming functions for details. inrange() is also useful in some cases like this.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html
An Introduction to Modern Econometrics Using Stata:
http://www.stata-press.com/books/imeus.html


*
* 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