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

st: RE: Another looping problem


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Another looping problem
Date   Fri, 4 Apr 2003 16:42:16 +0100

Joel Clovis
>
> I am (some may already know) trying to take a panel dataset
> and drop
> variables (by Country) that don't have enough observations
> (at least 35
> say).  I have the following dofile that asks me for another
> brace and I don't
> know why.  I've used 3 opening and 3 closing.
> >{ required
> >r(100);
>
>
> Q1.  Will this dofile achieve my goal?
> Q2.  Why do I need another brace? and if so where?
>
> I'm a Stata 7 user.  Can anyone help?
>
> Joel
>
> Dofile:
>
> foreach Country in  Argentina  Bangladesh  Botswana
> Brazil  Kenya  “Korea, Rep.”  Malaysia  Indonesia
> Ghana   “Taiwan, China”  Tanzania Zambia {
> 	drop if Country~=`Country'
> 	sort Year
> 	foreach v of var cba2tfina-region{
> 		qui count if !missing(`v')
> 		if r(N)<35{
> 				drop `v'
>                   }
> 		}
> outsheet using
> "P:\IDPM\DBASES\WBFinStruct\tst1\Splus`Country'X" ,
> comma replace
> keep RGDPCap
> outsheet using
> "P:\IDPM\DBASES\WBFinStruct\tst1\Splus`Country'Y" ,
> comma replace
> use
> "P:\IDPM\DBASES\WBFinStruct\tst1\FinStructSoc.dta",
> clear
> 	}

I have an over-arching comment that
your overall approach of splitting your
data set into lots of little data sets
is not, in my experience, a good strategy.
Rather, keep them in one set and exploit
the Stata structures which allow analysis subset
by subset. There are plenty of them.

Having said that, I suspect there is a bug
here on the line

	drop if Country~=`Country'

which probably should be

 	drop if Country~="`Country'"

but that wouldn't seem to be the problem
Stata is complaining about.

Linewraps interposed somewhere between
origin and destination may be obscuring
some issue.

Nick
n.j.cox@durham.ac.uk

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