Statalist The Stata Listserver


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

st: double loop issue


From   Molly Lipscomb <[email protected]>
To   [email protected]
Subject   st: double loop issue
Date   Fri, 16 Feb 2007 13:38:32 -0800 (PST)

Hi,
I have a loop inside a loop so that I can merge a file into another file by several different variables (I have data on cities, and I need to merge in the data on cities by each city crossed in each observation).
Right now I have the following code:
forvalues p=1/55 {
use C:\filename.dta
foreach var in capital spending investment transfers ...
ren `var' `var'_`p'
save C:\filename.dta
..and then I open up the master data and merge in the renamed variables.
}
}

The problem is that stata will only rename the first variable in my variable list--here capital, it ignores the other variables.
How do I fix this?
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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index