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   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   Re: st: Using a scalar/macro for loop limit in building Sureg equations
Date   Mon, 3 Nov 2008 23:47:51 +0100

Line for the server

Also see http://www.stata.com/statalist/archive/2008-10/msg00410.html

HTH
Martin
_______________________
----- Original Message ----- From: "Thomas Jacobs" <[email protected]>
To: <[email protected]>
Sent: Monday, November 03, 2008 11:45 PM
Subject: Re: st: Using a scalar/macro for loop limit in building Sureg equations


Maarten,

Thanks, both versions worked as you suggested.  Is there any reason
why a scalar is a bad choice here?  I ask because of the wording you
used about "insisting" upon it vs. "easier" to use a macro, etc.

Tom

On Mon, Nov 3, 2008 at 4:17 PM, Maarten buis <[email protected]> wrote:
--- 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/




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



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