Dear all,
I am currently trying to calculate a variable which is based on dividing values within a variable by other values of that variable. For example, this is an example of the data:
and the variable wanted is what I want to compute. I would like to compute the value of a divided by b, per country-year observation, so that wanted would give me the value 1/3 for the first two observations, and 9 for observation 4 and 5. This is just an example, I have multiple countries and years in the dataset, hence why I need to do this by country and year.
Any help on this is greatly appreciated.
Best,
Satya
I am currently trying to calculate a variable which is based on dividing values within a variable by other values of that variable. For example, this is an example of the data:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str3 country float year str1 variable float(value wanted) "USA" 2010 "a" 2 . "USA" 2010 "b" 6 . "USA" 2010 "c" 4 . "USA" 2011 "a" 9 . "USA" 2011 "b" 1 . "USA" 2011 "c" 3 . end
Any help on this is greatly appreciated.
Best,
Satya
Comment