Hello everyone,

I have received ~300 .sas7bdat files that I need to import to Stata and save them as .dta.
I searched the forum and found code that should work. I've tested it on a local folder containing two .sas7bdat files (named v1 and v2). See the code below.

Code:
local filenames : dir "B:\Test" files "*.sas7bdat"
foreach file of local filenames {
import sas using "`file'", clear local stata_name : subinstr local file ".sas7bdat" save `stata_name', replace
}
When I run this code I get the error:
"file v1.sas7bdat not found"
I've checked that the path and filename are correct.

Further, how do I implement a new save path for the .dta files? The SAS files are located in a RAW folder and I need to save them to a WORK folder (without making any changes to the RAW folder!). Any ideas how to include that in the above code?
Using Stata 16.

Thank you!