I am new to Stata and have been trying to generate the following variable.
Variable Definition: ten-year sum (from t-9 to year t) of net income divided by the ten-year sum of cost of goods sold less SG&A. The variable must be between 0 and 1
This is the code I have:
Code:
sort gvkey fyear ssc install asrol bys gvkey: asrol ni, gen(ni_sum) window (fyear 10) stat(sum) gen cogs2=cogs-sga bys gvkey: asrol cogs2, gen(cogs_sum) window (fyear 10) stat(sum) gen ni_t10=ni/cogs_sum drop if ni>1 drop if ni_t10<0
0 Response to Generating variables t-4 to 5
Post a Comment