Statalist


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

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


From   Maarten buis <[email protected]>
To   [email protected]
Subject   Re: st: Using a scalar/macro for loop limit in building Sureg equations
Date   Mon, 3 Nov 2008 22:17:57 +0000 (GMT)

--- Thomas Jacobs <[email protected]> wrote:
> 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 LnRtC
> > MT LnRtTED L(0/2).LnRtStock`i') "
>   3. }
> invalid syntax

If you insist on using a scalar in this context you can type:

forvalues i = 1/`=scalar(Count)' {

Easier is to store the count in a local:

summ Companies
local Count = r(max)
forvalues i=1/`Count'{

Hope this helps,
Maarten

-----------------------------------------
Maarten L. Buis
Department of Social Research Methodology
Vrije Universiteit Amsterdam
Boelelaan 1081
1081 HV Amsterdam
The Netherlands

visiting address:
Buitenveldertselaan 3 (Metropolitan), room N515

+31 20 5986715

http://home.fsw.vu.nl/m.buis/
-----------------------------------------


      
*
*   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/



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