Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


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

st: RE: RE: Difference of values in the same column/variable


From   "Gokhan Yilmaz" <yilmag@rpi.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: Difference of values in the same column/variable
Date   Tue, 15 Nov 2011 08:35:27 -0500

Thank you very much Dr. Cox

Gokhan

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Tuesday, November 15, 2011 4:58 AM
To: 'statalist@hsphsun2.harvard.edu'
Subject: st: RE: Difference of values in the same column/variable

In your example 

bysort time (group) : gen newvar = ewportnet - ewportnet[_n-1] 

Nick
n.j.cox@durham.ac.uk 

yilmag@rpi.edu

How can i create a new variable that is equal to the difference in ewportret
(see below table) between two groups in the same month?
For example: the first row of the newvar below would be equal to (.0375245-
.041679) and the second row would be equal to(.0397919- .0449738)


group	time	ewportret  newvar

1	2007m4	.0375245      
1	2007m5	.0397919
1	2007m6	-.0188678
0	2007m4	.041679
0	2007m5	.0449738
0	2007m6	-.0240277


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


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