Dear All, Suppose that I have the following data, i.e., 500 firms (id) over 20 years (year).
I wish to calculate the C-score (for each `id' and each `year') as described below:

Any suggestions are highly appreciated.
Code:
clear set obs 500 gen id = _n expand 20 bys id: gen year = _n+1999 set seed 123 gen X = rnormal() gen R = rnormal() gen D = (R<0) gen Size = rnormal() gen MB = rnormal() gen Leverage = rnormal()
Any suggestions are highly appreciated.
Comment