I have an unbalanced data of

company id
(i)
country code
(c)
year
(y)
ratio-1
(r1)
ratio-2
(r2)
ratio-3
(r3)
ratio-4
(r4)
ratio-5
(r5)
1 ≤ i ≤ 1587 1 ≤ c ≤ 18 2005 ≤ y ≤ 2021 0 ≤ r1 ≤1 0 ≤ r2 ≤1 0 ≤ r3 ≤1 0 ≤ r4 ≤1 0 ≤ r5 ≤1


where 1587 companies from 18 different countries report 5 different financial ratios annually from 2005 to 2021.

As such, there are 26979 rows (1587 * 17) in the data (1587 companies and 17 years) in which each company is assigned to a single country in all years.

I want to generate a new variable (Xa,y) for each and every row. Since I couldn't properly post the formula for Xa,y I attached it in a pdf file Array

Eventually, all companies should have a unique "Xa,y" for each year and 17 (number of years) different "Xa.y"s in total.

I appreciate your help with the code for Xa,y.

Best,

Lütfi