Dear Users,
I have 3 datasets:
datacomp_112022, dataplant_112022, and datainds_112022.
All the datasets have the same variables but they have different years (this is not an issue). I would like to run this code on all these data sets using a loop. If this is possible, could any one help please?
Thanks
The code is (I got this code in one of my previous questions on Statalist):
I have 3 datasets:
datacomp_112022, dataplant_112022, and datainds_112022.
All the datasets have the same variables but they have different years (this is not an issue). I would like to run this code on all these data sets using a loop. If this is possible, could any one help please?
Thanks
The code is (I got this code in one of my previous questions on Statalist):
Code:
bysort comp year: gen which = sum(code_a != code_a[_n-1]) forval j = 1/3 { egen code_a`j' = mean(cond(which == `j', code_a, .)), by(comp year) }

Comment