Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nima Darbari <ramharz@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: Stacking variables |
Date | Fri, 20 Dec 2013 10:21:53 +0100 |
Dear Nick Indeed now I think about it reshaping is much easier here. Best Nima On Mon, Dec 16, 2013 at 2:34 PM, Nick Cox <njcoxstata@gmail.com> wrote: > A different comment is that, on this information, -reshape- might be a > better solution than -stack-. > Nick > njcoxstata@gmail.com > > > On 16 December 2013 13:06, 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/ * * 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/