I am in the process of creating 718 different data files based off of one master dataset. I am running a basic loop, keeping the variables created, saving them as their own dta file, and then starting again. The way I'm doing it is not efficient though, and I'm wondering if there is a better way.
Currently I am running the following code:
Code:
use "S:\elzayaty\Mobility paper\INDUSTRY DIVERSIFICATION DISTANCE DATA.dta", clear forval x = 1/718 { bysort investorid: gen prod_1`x' = ever_1 * ever_`x' } keep investorid prod* save "S:\elzayaty\Mobility paper\prod1.dta", replace ************************************************** use "S:\elzayaty\Mobility paper\INDUSTRY DIVERSIFICATION DISTANCE DATA.dta", clear forval x = 1/718 { bysort investorid: gen prod_2`x' = ever_2 * ever_`x' } keep investorid prod* save "S:\elzayaty\Mobility paper\prod2.dta", replace
Any thoughts on how to address this would be greatly appreciated!
-Andy
0 Response to Creating a more efficient loop for generating multiple datasets
Post a Comment