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

st: Going Loopy!!


From   "Joel Clovis" <[email protected]>
To   [email protected]
Subject   st: Going Loopy!!
Date   Mon, 7 Apr 2003 14:50:40 +0000

Dear Statalisters,

I'd like to thank every one who offered help to my 
looping problems, especially Nick Cox, David Kantor.

The code I ended up with (not below) was messy, 
requiring me to repeat some earlier loop for each 
country in an ado.file (6 ado.files actually,..,yuk!).

The code below was the best attempt to avoid the 
above.  Whilst it loops through all the countries, 
the output still includes variables with only a few 
observations. And I'm not sure why..can it be the 
!missing operator ignors "." for missing observations?



Thanks for all (any) help.


Joel Clovis
Joel

clear
set memory 80m
log using 
P:\idpm\dbases\WBFinStruct\tst1\Tstestlog2.log, 
replace
use 
"P:\IDPM\DBASES\WBFinStruct\tst1\FinStructSoc.dta", 
clear
sort Country Year
cd "P:\IDPM\DBASES\WBFinStruct\tst1" 
 
foreach C in South Africa Spain "St. Kitts and Nevis" 
"St. Lucia" "St. Vincent and the Grenadines" Sudan 
Suriname Swaziland Togo Tunisia {
	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' using "Splus`C'X" if Country 
== "`C'"  , comma replace
 	outsheet RGDPCap using "Splus`C'Y" if Country 
== "`C'" , comma replace
  }	

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