# Help with First Differencing in STATA

#### Ekhanolkar18

##### New Member
Hello
I am a student working with STATA for the first time. I am using panel data for the English Premier League football from 2010 to 2015 and am having trouble with first differencing my data to control for unobserved heterogeneity. Overall, I am interested in how a team's total player salary explains performance through statistics like total wins, shots, crosses, goalkeeper saves, and blocks

I have the 10 teams I am looking at in the observations column and have set up my statistics of interest as variables distinguished by year (i.e., Wins2010, Wins2011, etc.).

Do I need to rearrange my data in order to do first differencing in STATA or is there a way to input the function so that I have 5 dummy variables to account for the different years?

Any help is greatly appreciated!

#### maartenbuis

##### TS Contributor
Situations like these are almost always much easier in "long" format, see help reshape. After that you declare your data to be a time series with tsset and use the lag operator. Below is an example:

Code:
clear all

// some example data
input team wins2010 wins2011 wins2012 wins2013 wins2014 wins2015
1 1 2 3 4 5 6
2 0 0 0 1 1 1
3 9 9 9 9 9 9
end

// reshape
reshape long wins , i(team) j(year)

// declare time series (within teams)
tsset team year

// create differences
gen dwins = d.wins

list, sepby(team)