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

Re: st: manual first differencing

From   Eva Poen <>
Subject   Re: st: manual first differencing
Date   Mon, 16 Mar 2009 16:12:55 +0000


if you tell us what your ultimate goal is, we might be able to provide
better advice. Your command only gives correct results if
a) your data is already sorted by year, and
b) there are no gaps in your variables.

A better version is

generate fdpop = d.pop

which will take care of those things automatically.

However, you can also use the d. operator in regressions, e.g.

regress yvar d.pop

without actually creating the variables. If you do want to create the
variables, use a loop (see -help forvalues-).


2009/3/16 Nola Agha <>:
> Hi -
>   I'd like to first difference all of the variables in my equation.  I have a
> panel dataset which is -xtset dmaid year-.  The following command seems to work
> quite well for one of my variables:
> by dmaid, sort: generate fdpop=pop[_n]-pop[_n-1]
> I'm wondering:
> a) if there is a built-in command to do this for an entire equation (as opposed
> to doing it variable by variable)?
> b) if not, if there is a way to automate this procedure for all of my (many)
> variables?
> Thanks,
> Nola

*   For searches and help try:

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