Thanks for your suggestions, I guess I wasn't as clear
as I meant to be.
The reason that I am renaming and merging the file in
so many times is that I need distance weighted
averages of about 150 variables over 55 counties for
each observation. This would make the matrix size
much too large if I tried to do it in a single
command, so I am trying to use a look and use running
sums of each of the variables.
Here is the actual code that I was using (with some of
the variables in the loop removed to reduce space):
forvalues p=1/55 {
use C:\Brazil\Munisplits\mergingdata.dta
foreach var in capital_spending1990
health_sanitation_spending1990 investment1990
transfers1990 assessed_municipal_share1990 plus more
variables {
ren `var' `var'_`p'
ren muni muni`p'
sort muni`p'
save C:\Brazil\Munisplits\averagesloop.dta, replace
use C:\Brazil\Munisplits\root.dta
sort muni`p'
merge muni`p' using
C:\Brazil\Munisplits\averagesloop.dta
tab _merge
drop if _merge==2
drop _merge
replace `var'_r=`var'_r+`var'_`p'*routelength`p' if
`var'_`p'!=. & routelength`p'!=.
replace `var'_d=`var'_d+routelength`p' if `var'_`p'!=.
& routelength`p'!=.
drop
capital_spending1990_`p'-adequate_drainage2000_`p'
save C:\Brazil\Munisplits\root.dta, replace
}
}
Thanks!
Molly
____________________________________________________________________________________
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php
*
* 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/