Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Fwd: Retrieving macros defined inside for loop
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: Fwd: Retrieving macros defined inside for loop
Date
Tue, 19 Nov 2013 22:03:09 +0000
What the difficulty is here is not clear. In your case, macros defined
within the loop that are not the loop index should remain visible. I
suspect a different problem, trying to access them in a different
locale.
. forval j = 1/6 {
2. local c_`j' `j'
3. }
. mac li
S_level: 95
F1: help
F2: #review;
F3: describe;
F7: save
F8: use
S_ADO: UPDATES;BASE;SITE;.;PERSONAL;PLUS;OLDPLACE
S_StataSE: SE
S_FLAVOR: Intercooled
S_OS: Windows
S_MACH: PC
_c_6: 6
_c_5: 5
_c_4: 4
_c_3: 3
_c_2: 2
_c_1: 1
Nick
[email protected]
On 19 November 2013 21:43, Laura Grant <[email protected]> wrote:
> Simple question. I want to retrieve macros once outside the loop that
> are defined inside the loop.
>
> I do -regress- , then I have a loop to perform -lincom- t-tests
> comparing stored coefs
>
> reg y star0 star1 star2 star3 star4 star5 star6 star7 x1 x2 x3
>
>
> forval i = 0/6 {
> local j = `i'+1
> lincom star`j' - star`i'
> local c_`j'= r(estimate)
> local se_`j'=r(se)
> display `c_1'
>
> }
>
> -display- works inside the loop but I cannot retrieve the c_j's and
> se_j's outside the loop. And I would like to output them to a
> table/text.
>
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/