Statalist The Stata Listserver


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

st: foreach-question


From   Johannes Geyer <[email protected]>
To   [email protected]
Subject   st: foreach-question
Date   Fri, 21 Apr 2006 12:36:06 +0200

Dear Statalist,

it seems to me that I did not understand the Syntax of "foreach", I typed the code below to produce a panel data set for which I had to rename some variables and added an index(1995,1996,1997,...,2004) as suffix. The loop works perfectly well until it reaches the last variable "kzahl". I do not know why but the last variable is not processed in the loop. Has anyone an idea where I made a mistake?

Thanks for your help,
Johannes

local wave = "l m n o p q r s t u"
local vars = "netto pbleib pbbil01 pbbil02 pbbil03 phrf famstd stell pnat nace psbil hhgr eigen kzahl"
local y    = 1995

foreach x in `wave' {

local y = `y' + 1
}


___________________
Johannes Geyer
Deutsches Institut f�r Wirtschaftsforschung (DIW Berlin)
German Institute for Economic Research
Koenigin-Luise-Stra�e 5
14195 Berlin, Germany
Tel: +49-30-89789-258



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