Statalist The Stata Listserver

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

st: double loop issue

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

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?

The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.

*   For searches and help try:

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