David Kantor
> 
> In response to Joel Clovis's question, I might add...
> 
> >         drop if Country~="`Country'"
> 
> With this being in the loop, after it executes in the 
> second iteration, you 
> will have no observations left.  (Unless you -use- your 
> basis set each 
> time, but that was not included in that loop.)
> 
The last statement within the outer -foreach- 
seems to read in the main data set once more. 
This points up that it would be more efficient to 
do something more like this:  
use <datafile>
sort Country Year 
cd "P:\IDPM\DBASES\WBFinStruct\tst1" 
foreach C in <list> {
	local OKvars
	foreach v of var cba2tfina-region {
		qui count if !missing(`v') & Country == "`C'" 
		if r(N) >= 35 {
			local OKvars "`OKvars'`v' " 
            }
	}
	outsheet `OKVars' if Country == "`C'" 
		using "Splus`Country'X" , comma replace
	outsheet RGDPCap if Country == "`C'" 
            using "Splus`Country'Y" , comma replace
}	
Nick 
[email protected] 
*
*   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/