I have many stata data files (originally from excel spreadsheets) I am trying to organize into a useable data set
Each of the stata data files has data on about 50 cities (the observations) and the results of 1 to 6 simulations. Each simulation gives multiple results (variables) and takes multiple parameters.
I would like to make a file for each simulation. Variables on the data set describe the simulations (e.g. a $200K house in 2006 with no assessment limit, this is the same across all cities). I would like to embed this description in the newly-saved file name. Unfortunately it is not easy to put this in a loop (or use the reshape command) since some simulations have more results than others
My (unsatisfactory) code thus far is (generically) [I've simplified the names of the variables and parameters here]
The problem is that the command save `file_name1' names the saved file a name like "file __000004.dta" rather than the text assigned to the scalar.
use "top50 home 2005.dta", clear
preserve
generate simulation_name=B
keep simulation_name State City result1 result2 param1 param2 param3
tempname file_name1;
scalar `file_name'=B[1];
save `file_name1'
restore, preserve
generate simulation_name=H
keep simulation_name State City result3 result4 param4 param5 param6
tempname file_name2;
scalar `file_name'=H[1];
save `file_name2'
Thanks for any help.
Each of the stata data files has data on about 50 cities (the observations) and the results of 1 to 6 simulations. Each simulation gives multiple results (variables) and takes multiple parameters.
I would like to make a file for each simulation. Variables on the data set describe the simulations (e.g. a $200K house in 2006 with no assessment limit, this is the same across all cities). I would like to embed this description in the newly-saved file name. Unfortunately it is not easy to put this in a loop (or use the reshape command) since some simulations have more results than others
My (unsatisfactory) code thus far is (generically) [I've simplified the names of the variables and parameters here]
The problem is that the command save `file_name1' names the saved file a name like "file __000004.dta" rather than the text assigned to the scalar.
use "top50 home 2005.dta", clear
preserve
generate simulation_name=B
keep simulation_name State City result1 result2 param1 param2 param3
tempname file_name1;
scalar `file_name'=B[1];
save `file_name1'
restore, preserve
generate simulation_name=H
keep simulation_name State City result3 result4 param4 param5 param6
tempname file_name2;
scalar `file_name'=H[1];
save `file_name2'
Thanks for any help.
Comment