I have the following problem. I have defined 3 local variables defining the path to some folders containing 3 different .dta files.
What I would like to do actually is open each file separately and work on it in a single loop. The pseudo code should read something like this:
Code:
local folder_product "/Users/federiconutarelli/Desktop/PhD/Lavoro_Riccaboni/DATi_USA/Pharma_project_2019 /prodmol_aggregation" local folder_firm "/Users/federiconutarelli/Desktop/PhD/Lavoro_Riccaboni/DATi_USA/Pharma_project_2019 /firm_aggregation" local folder_atc2 "/Users/federiconutarelli/Desktop/PhD/Lavoro_Riccaboni/DATi_USA/Pharma_project_2019 /ATC_aggregation" local aggr "product firm atc2" tokenize `aggr' // syntax (cfr help tokenize) foreach y in `aggr'{ local filelist: dir "`folder_"+`1' files "DB_" + `1' + "_aggregation.dta" // where `1' should be "product" in the token right? foreach file of local filelist { use "`file'", clear [DO SOME STUFFS] } local filelist: dir "`folder_"+`2' files "DB_" + `2' + "_aggregation.dta" // where `2' should be "firm" foreach file of local filelist { use "`file'", clear [DO SOME STUFFS] } local filelist: dir "`folder_"+`3' files "DB_" + `3' + "_aggregation.dta" // where `3' should be "atc2" in the token right? foreach file of local filelist { use "`file'", clear [DO SOME STUFFS] } }
Thanks,
Federico
0 Response to Tokenize and looping through tokens
Post a Comment