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

From |
"Martin Weiss" <martin.weiss1@gmx.de> |

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

Subject |
st: Re: Using a scalar/macro for loop limit in building Sureg equations |

Date |
Mon, 3 Nov 2008 23:13:29 +0100 |

Use a -local- or just write forvalues i=1/`=Count'{ .... } HTH Martin _______________________

To: "StataList" <statalist@hsphsun2.harvard.edu> Sent: Monday, November 03, 2008 10:58 PM Subject: st: Using a scalar/macro for loop limit in building Sureg equations

I am trying to build a more flexible do file process in working with a varying number of firms for which I wish to estimate seemingly unrelated regressions with sureg. The code I have now is *BEGIN HERE *sureg drop all unnecessary variables keep TradeDateNum CompanyNum LnRt* egen Companies=group(CompanyNum)reshape wide CompanyNum LnRtStock LnRtFiveYrMid, i(TradeDateNum)j(Companies)tsset TradeDateNum forvalues i=1/54{ local eqn "`eqn' (LnRtFiveYrMid`i' L(1/2).LnRtFiveYrMid`i' L(0/4).LnRtCDX LnRtCMT LnRtTED L(0/2).LnRtStock`i') " } sureg `eqn',corr *END HERE CompanyNum is a label matched list of companies which will vary with the time line examined so I cannot use CompanyNum as a loop descriptor since it will not be contiguous. Thus I create the Companies variable which is contiguous via the group command. However, I have been unable to figure out how to use either a scalar or local macro with the maximum value of Companies for implementing the loop. Right now I have the current number of firms, 54, hardcoded. For instance I have tried: summ Companies scalar Count = r(max) but I keep getting errors when I try to substitute Count into my forvalues statement: . . forvalues i=1/Count{ 2. local eqn "`eqn' (LnRtFiveYrMid`i' L(1/2).LnRtFiveYrMid`i' L(0/4).LnRtCDX LnRtCMT LnRtTED L(0/2).LnRtStock`i') "3. } invalid syntax Can someone suggest how best to do this? Thanks. Tom -- Thomas Jacobs * * 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/

**Follow-Ups**:**Re: st: Re: Using a scalar/macro for loop limit in building Sureg equations***From:*"Thomas Jacobs" <thomasjacobs@gmail.com>

**References**:**st: Using a scalar/macro for loop limit in building Sureg equations***From:*"Thomas Jacobs" <thomasjacobs@gmail.com>

- Prev by Date:
**Re: st: Skewness estimates with svyset data** - Next by Date:
**Re: st: Using a scalar/macro for loop limit in building Sureg equations** - Previous by thread:
**st: Using a scalar/macro for loop limit in building Sureg equations** - Next by thread:
**Re: st: Re: Using a scalar/macro for loop limit in building Sureg equations** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |