Dear Statalisters,
I need to generate another variable called 'difference' which contains the difference between 'consecutive' median_gnp values based on year_cat.

Code:
clear
input float(median_gnp year year_cat)
 3730.3 1962 0
 3730.3 1962 0
 3730.3 1963 0
 3730.3 1963 0
   4441 1964 1
   4441 1964 1
   4441 1965 1
  4441 1965 1
5232.05 1966 2
5232.05 1966 2
5232.05 1967 2
5232.05 1967 2
 5912.6 1968 3
 5912.6 1968 3
 5912.6 1969 3
 5912.6 1969 3
 6833.95 1970 4
6833.95 1970 4
end
What I mean is that I need a variable diff that contains the values 4441 - 3730.3, 5232.05-4441, 5912.6-5232.05, and so on. (Basically, the 'diff' variable will show the growth in gnp year_cat wise)

This is a sample. My original dataset has around >50000 observations and >100 categories and my purpose is to make a 'growth' chart. The data is categorical - NOT time series or panel. I am on Stata/IC 16.1.