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
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.
0 Response to Difference in Consecutive Values by Group Labels
Post a Comment