Statalist The Stata Listserver


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

st: RE: Creating loops to drop observations each time regression is run


From   "Thuy Le" <tl6775a@american.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Creating loops to drop observations each time regression is run
Date   Sat, 01 Apr 2006 11:32:06 -0500

You can use the 'foreach'. See help on 'foreach' for details. 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Samia Tavares
Sent: Saturday, April 01, 2006 10:29 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: Creating loops to drop observations each time regression is run

Hi everyone!

I have a panel consisting of different countries for a number of years. I am
trying to write a program that would tell Stata to run a regression while
each time dropping a particular country (in other words, all the years for
which that country has observations). All I have so far is the manual
version:

use dataset.dta, clear
drop if code=="country1"
regress y x

use dataset.dta, clear
drop if code=="country2"
regress y x

and so forth. I am clueless as to how to write programs, so any help will be
immensely appreciated!!

Samia
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index