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   Nima Darbari <ramharz@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Stacking variables
Date   Mon, 16 Dec 2013 14:20:34 +0100

Thank you for your time Daniel, its strange how sometimes you can't
see the mistake although reading the code over and over

On Mon, Dec 16, 2013 at 2:06 PM, daniel klein <klein.daniel.81@gmail.com> 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