I have list of firms (gvkey) and years (fyear). Per each firm-year observation, I have monthly sales across columns (columns sale_1 through sale_12 for January sales to December sales). I’d like to compare sales every month (e.g., January to February, February to March and so on) and create 11 set of variables for each difference (e.g., diff_2=sale_2-sale_1 and so on). Is there array or do loop I can use to create these variables instead of writing diff_2 through diff_12?
I was thinking of creating proc sql to merge every month but that sounds even longer.