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

From |
Kit Baum <baum@bc.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: re: r(198) error |

Date |
Fri, 7 Sep 2007 15:59:47 -0400 |

Nirina said

What I basically want to do is:

1- to run the regression using the variables stored in the list of

variables LHS to be used one by one as a dependent variable and then

outreg each result in the table.

2- this another related question where:

say I have a list of RHS x1.....x12

and I want to regress y $RHS

but I would like to see use on variable in RHS increasingly ie

reg y x1

reg y x1 x2

reg y x1 x2 x3 etc.....

Thank you very much for your help

Nirina

On 8/15/07, Kit Baum <baum@bc.edu> wrote:

> Your expansion of the macro outfile_reg probably contains spaces plus

> the word 'and'. You probably need to use compound double quotes

> (q.v.) or use a directory without embedded spaces in its name on your

> machine.

>

>

> Kit Baum, Boston College Economics and DIW Berlin

> http://ideas.repec.org/e/pba1.html

> An Introduction to Modern Econometrics Using Stata:

> http://www.stata-press.com/books/imeus.html

>

>

> On Aug 15, 2007, at 2:33 AM, statalist-digest wrote:

>

> >

> > Could anyone let me know what is wrong with the following do. file to

> > give me an invalid 'and' r(198).

> >

> >

> > /*foreach x of varlist $LHS {;

> > local xtitle "`x' OLS" ;

> > local outfile_reg "$dataloc/Results/reg_`x'" ;

> > regress `x' $RHS, robust;

> > outreg using "`outfile_reg'", ctitle("`xtitle'") append;

> > };

> > */;

> >

> > invalid 'and'

> > r(198);

> > Thank you,

>

In the code insert a line after the definition of outfile

display "`outfile_reg'"

I imagine you will find the word " and " in that local. That will cause problems.

Furthermore this could be done more easily as

eststo clear

foreach x of varlist $RHS {

eststo: reg `x' $RHS, robust

local xtitle "`xtitle `x'"

}

esttab using results.log, mtitles(`xtitle')

and you don't need to create all those files. Just -ssc install estout-.

For your 2d question,

forv i=1/12 {

local reg "`reg' x`i'"

reg y `reg'

}

The "A little bit of Stata programming goes a long way" papeer mentioned in my recent postings would be useful.

Kit

Kit Baum, Boston College Economics and DIW Berlin

http://ideas.repec.org/e/pba1.html

An Introduction to Modern Econometrics Using Stata:

http://www.stata-press.com/books/imeus.html

*

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

**Follow-Ups**:**Re: st: re: r(198) error***From:*"Ben Jann" <ben.jann@gmail.com>

- Prev by Date:
**st: competing risks** - Next by Date:
**st: Incorporating variable labels into the variable name** - Previous by thread:
**st: Re: r(198) error** - Next by thread:
**Re: st: re: r(198) error** - Index(es):

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