Hi,
I am trying to open, create a couple of variables, and then save a group of datasets in a different folder in a loop but is not working. The datasets open, the creation of variables work but the datasets do not save in the folder correctly. I want to save the datasets using the same names they have original. This is the code that I am using:
global path "C:/Users/tessamay/folder"
global raw "${path}/Data/Raw"
global temp "${path}/Data/Temp"
foreach x in 2019 2020 2021 2022 2023{
use "${raw}/`x'.dta", clear
{…}
save "${temp}/ `x'.dta", replace
}
Thanks,
Tessa
I am trying to open, create a couple of variables, and then save a group of datasets in a different folder in a loop but is not working. The datasets open, the creation of variables work but the datasets do not save in the folder correctly. I want to save the datasets using the same names they have original. This is the code that I am using:
global path "C:/Users/tessamay/folder"
global raw "${path}/Data/Raw"
global temp "${path}/Data/Temp"
foreach x in 2019 2020 2021 2022 2023{
use "${raw}/`x'.dta", clear
{…}
save "${temp}/ `x'.dta", replace
}
Thanks,
Tessa
Comment