Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: Re: forvalues problem


From   "Zhiqiang Wang" <wang@sun0.menzies.edu.au>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: forvalues problem
Date   Thu, 1 Aug 2002 14:32:28 +0930

Fred
Your codes appear fine to me.  I haven't checked the Stata manual. I guess
that -foreach- may not get along well with glabol macro -{}-. To avoid this,
change the lines as follows:

forvalues j = 1 /  2 {
    local newnum=${catvar`j'_totline}
    forvalues k = 1 / `newnum' {
        di "....'"
    }
}


Zhiqiang

-----------------------
Zhiqiang Wang
Menzies School of Health Research
Darwin Australia


----- Original Message -----
From: "Fred Wolfe" <fwolfe@arthritis-research.org>
To: <statalist@hsphsun2.harvard.edu>
Sent: Thursday, August 01, 2002 12:44 PM
Subject: st: forvalues problem


> Can anyone see the problem?
>
> I have global macros
>
> mac list
> catvar1_totline: 2
> catvar2_totline: 9
>
> When I try to use them with the following code I get an error
>
>        forvalues j = 1 /  2 {
>           forvalues k = 1 / ${catvar`j'_totline} {
>           di "`k'. ${catvar`j'vname`k'"
>           }
>        }
>
> The error is:
>
> - forvalues k = 1 / ${catvar`j'_totline} {
> unrecognized command:  catvar1_totline
>
> Leaving the braces off gives "invalid syntax."
>
> . di ${catvar1_totline}
> 2
>
>
> Thanks
>
> Fred
>
>
>
>
>
>
> --------------------------------------------------------------------------
--
> ------------------------
> Fred Wolfe                                                          Tel
> (316) 263-2125
> National Data Bank for Rheumatic Diseases         Fax (316) 263-0761
> Wichita,
> Kansas                                    fwolfe@arthritis-research.org
> --------------------------------------------------------------------------
--
> -------------------------
>
> *
> *   For searches and help try:
> *   http://www.stata.com/support/faqs/res/findit.html
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
>

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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