Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: RE: first-difference command

From   Mauro Mastrogiacomo <[email protected]>
To   "'[email protected]'" <[email protected]>
Subject   st: RE: first-difference command
Date   Fri, 16 Sep 2011 21:40:38 +0200

Sorry I missed your original message but I suppose you want to code:
bys firmcode: gen dx = x-x[_n-1]

another option could be:
xtset firmcode year
gen dx=D.x


-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of donsaane dontsi
Sent: vrijdag 16 september 2011 21:27
To: [email protected]
Subject: st: first-difference command

Thanks Austin, 
Maybe I was misunderstood. My panel dataset is sort by
year, so I have : 
firmcode year 
1        2006
1        2009
2        2006
2        2009
I want to first-difference all my variables in order to
be x[2006-2009]
Can I just do: gen dx=x-x[_n-1]
Thanks for the help


*   For searches and help try:

Dit bericht kan informatie bevatten die niet voor u is bestemd. Indien u niet
de geadresseerde bent of dit bericht abusievelijk aan u is toegezonden, wordt
u verzocht dat aan de afzender te melden en het bericht te verwijderen.
De Staat aanvaardt geen aansprakelijkheid voor schade, van welke aard ook, die
verband houdt met risico's verbonden aan het elektronisch verzenden van

This message may contain information that is not intended for you. If you are
not the addressee or if this message was sent to you by mistake, you are
requested to inform the sender and delete the message. The State accepts no
liability for damage of any kind resulting from the risks inherent in the
electronic transmission of messages.

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index