Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Stata programming: While Command


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Stata programming: While Command
Date   Mon, 3 Mar 2008 13:48:19 -0000

You have already had good answers. 

In addition, note that the consequence of your definition

local industria "ind1 ind2 ind3 ind4 ind5 ind6 ind7 ind8 ind9"

is that the line 

while `industria' == 1 {

is seen by Stata as 

while ind1 ind2 ind3 ind4 ind5 ind6 ind7 ind8 ind9 == 1 { 

That is illegal and not what you want anyway. 

As Eva pointed out, you need better ways of doing this. 

Leonor Saravia

I'm learning how to make some programs in Stata, but Im having
problems in using the 'while' command.

My database looks like this:

FIRM_ID         IND1   IND2    IND3 .....IND9   TAX      INV
120                  1        0         0          0         0.16     100
123                  0       1          0          0        0.16      200
120                  1        0         0          0         0.15     150
134                  0        0         0          1         0.16     180
123                  0        1         0          0         0.15     200
134                  0        0         0          1         0.15     120
.
.
123                  0        1         0          0         0.17     130

I need to do a two step regression by the variable IND, this is:  when
IND1==1, IND2==1, IND3==1, ...,IND9==1, I need that Stata runs this
programm:
                                                         First step:
regress TAX EXP, robust

   predict tax_hat
                                                         Second step:
xtreg INV tax_hat, fe
                                                                           end

So, what I was trying to do in my do-file was (and it's not working):

local industria "ind1 ind2 ind3 ind4 ind5 ind6 ind7 ind8 ind9"

while `industria' == 1 {

reg tax exp, robust

predict double tax_hat

xtreg ln_inv tax_hat, fe vce(bootstrap)

drop tax_hat

}

But when I do this, Stata gives me this message:     program error:
code follows on the same line as open brace


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