Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Eric Booth <eric.a.booth@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: AW: AW: Regressions with constant independent variable |

Date |
Wed, 11 Apr 2012 07:41:31 -0500 |

<> Hi Fabian: You could change your current code to: g first = . forval n = 1/`=_N' { bys cusip (fyear): replace first = lnsales[`n'] /// if lnebit[`n']!=0 & mi(first) } to get those values. - Eric __ Eric A. Booth Public Policy Research Institute Texas A&M University ebooth@ppri.tamu.edu +979.845.6754 On Apr 11, 2012, at 4:45 AM, Fabian Schönenberger wrote: > Many thanks! I have used: > By cusip (fyear), sort: generate firstlnsales=lnsales[1] if (lnebit [1] > !=0). This one works fine. > However, I would like to adjust the formula, in order to get observation 2 > if lnebit [1] is 0, and then observation 3 if observation 2 is 0 and so on. > Any suggestions? > > Best, Fabian > > > > -----Ursprüngliche Nachricht----- > Von: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Dithmer, Jan > Gesendet: Mittwoch, 11. April 2012 10:49 > An: statalist@hsphsun2.harvard.edu > Betreff: st: AW: Regressions with constant independent variable > > If you want to create a new variable, s.th like the following may work (if I > understand you correctly): > > by cusip: gen salesinitial = sales if fyear=="first observation of fyear" > by cusip: replace salesinitial = salesinitial[_n-1] if salesinitial==. > > It may be possible to do it in one step, but unfortunately I don't know how > and would also be interested in a shorter solution. > > Best, Jan > > -----Ursprüngliche Nachricht----- > Von: owner-statalist@hsphsun2.harvard.edu > [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von Fabian > Schönenberger > Gesendet: Wednesday, April 11, 2012 8:55 AM > An: statalist@hsphsun2.harvard.edu > Betreff: st: Regressions with constant independent variable > > Dear Statalist > I would like to run a regression like Y=a + b*x + c*z + e for panel data. ID > is cusip, and t is fyear, x is sales and z is growth of sales. > I would like to keep x fixed for each cusip at the level of the first > observation of fyear. > Do I need to create a new variable or can I adjust my regression formula? > Many thanks in advance. > > FS > > * > * 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/ > > > * > * 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/

**References**:**st: Regressions with constant independent variable***From:*Fabian Schönenberger <fabian.schoenenberger@gmail.com>

**st: AW: Regressions with constant independent variable***From:*"Dithmer, Jan" <jdithme@food-econ.uni-kiel.de>

**st: AW: AW: Regressions with constant independent variable***From:*Fabian Schönenberger <fabian.schoenenberger@gmail.com>

- Prev by Date:
**Re: st: Multicollinearity and Time Trends** - Next by Date:
**Re: st: Some basic help on programming** - Previous by thread:
**st: AW: AW: Regressions with constant independent variable** - Next by thread:
**st: labels in -hbar- with over() and sort() specified** - Index(es):