Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

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

From |
William Buchanan <william@williambuchanan.net> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: st: foreach and forvalues combined |

Date |
Wed, 4 Jul 2012 07:20:52 -0700 |

Just saw the rest of your problem. replace sizebmp5=10+`i' if bm<bm4 & sizep5==`i' & timeyear==`t' Might solve your problem. HTH, Billy Sent from my iPhone On Jul 4, 2012, at 7:02, "Fabian Schönenberger" <sch.f@gmx.ch> wrote: > Dear Statalist > > I am facing the following challenge with my panel data while trying the form different portfolios (double ranking with size and BM-ratio). After generating the variable sizebm5 with: > > generate sizebmp5=11 if bm<bm4 & sizep5==1 & timeyear==1975 > > I want to loop the conditions sizep5== and timeyear==. Sizep5 is a variable consisting of numbers from 1 to 5 (1 small companies, 5 large companies). Timeyear is the time variable, 1975 to 2012. I am trying the following: > > > . foreach i of sizep5 1/5 { > 2. forvalues t = 1975/2012 { > 3. replace sizebmp5=1`i' if bm<bm4 & sizep5==`i' & timeyear==`t' > 4. } > 5. } > > However Stata says invalid syntax. I guess the problem is with sizebmp5=1`i' -> 1 stands for the first condition bm<bm4 (I will change this condition manually and then switch to 2 and so on). With `i' I want the variable signalling the corresponding sizep5 portfolio. Because this variable changes from 1 to 5, I need the term `i'; I also tried 1_`i' but it did not work. > > Any suggestions to solve this problem? > > Many thanks in advance. > > Thx, Fabian > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/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/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: foreach and forvalues combined***From:*"Fabian Schönenberger" <sch.f@gmx.ch>

- Prev by Date:
**Re: st: foreach and forvalues combined** - Next by Date:
**Re: st: Mergining horozontally excel files under a particular patern** - Previous by thread:
**Re: st: foreach and forvalues combined** - Next by thread:
**st: dropped from div() using xtabond or xtdpdsys** - Index(es):