first -difference command when year is repeated


New Member
In a previous posted I asked how to run first -difference command in a panel
The command that works is

tsset ccode year
g Dx = x-L.x

I would like to know how to run a first difference comand when observations are repeated for some years. I mean for some theoretical reason I am taking the observation of the same year more than once

In other words in a casual example just to make it more clear

year var1 var2 etc
1990 2 2
1990 2 2
1991 5 5
1992 4 4
1992 4 4
1992 4 4
1993 7 7

and so on.

If I take the first difference for those repeated years the values will be zeros which is not what I want.Any ideas how to solve ?