Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Stacking variables

From   daniel klein <>
To   "" <>
Subject   Re: st: Stacking variables
Date   Mon, 16 Dec 2013 14:06:58 +0100

I stopped reading at

foreach var of PreturnoverEvent1-PreturnoverEvent55{

Read the help file for -foreach- to learn that
PreturnoverEvent1-PreturnoverEvent55 is, of course, not a legal list
type. You probably want

foreach var of var PreturnoverEvent1-PreturnoverEvent55 {

Also note that there should be a space between PreturnoverEvent55 and
the brace (i.e. {). There might be more errors in the code, but I
guess you should be able to catch them, reading the respective help
files caerfully.


Dear All
[...] I wrote the code below but for some 'invalid syntax' error it didn't work.

gen PreEventTurnover=.
foreach var of PreturnoverEvent1-PreturnoverEvent55{
local first=((real(substr("`var'",17,2))*371)-370)
local last=(real(substr("`var'",17,2))*371)
local c=1
forvalues d=`first'(1)`last'{
replace PreEventTurnover= `var'[`c'] in `d'
local c=`c'+1

Can anyone help?
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index