Bookmark and Share

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


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

st: Stacking variables


From   Nima Darbari <[email protected]>
To   [email protected]
Subject   st: Stacking variables
Date   Mon, 16 Dec 2013 12:37:35 +0100

Dear All
To stack 55 variables (each with 371 observations) 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
}
}

Of, course later on I learned how to use the 'stack' command for the
purpose but I am still interested to know why did I receive 'invalid
syntax' for the code above. Can anyone help?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


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