Hi stata people, I need to use the name of the file to rename variables. I have multiple files that have common variable (mean). I need to rename mean to mean_filename to specify the variable. Here is my example:
As you could see,
would not work. I have tries "" and many other tricks.
Saleh
Code:
clear local myfilelist : dir . files"*.csv" foreach file of local myfilelist { drop _all insheet using `file' rename mean mean_filename local outfile = subinstr("`file'",".csv","",.) save "`outfile'", replace }
Code:
rename mean mean_filename
Saleh
Comment