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]

Re: st: Stacking variables


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Stacking variables
Date   Mon, 16 Dec 2013 13:34:00 +0000

A different comment is that, on this information, -reshape- might be a
better solution than -stack-.
Nick
[email protected]


On 16 December 2013 13:06, daniel klein <[email protected]> wrote:
> 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.
>
> Best
> Daniel
>
> --
> 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:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   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