File paths in statistical software

less than 1 minute read


On this page:

A short thread (PSA) on a FOC (frequently occurring problem) that shouldn’t be one: file paths in statistical software.

Comment in a recent reply to one of our replication reports (note: this was not actually a problem):

“We use a HPC and a Linux environment. Therefore, the folders are separated by / and not \ . This might create problems if working with Windows.”

Actually, it does not!


Every Stata user (but in particular those on Windows) should know 👇. Rule: ALWAYS use “/”, NEVER “\” and you should be fine.

Stata note on paths


use “file.path('path','file')” or even use packages here or rprojroot.


Use “/” and it will do the right thing.

Matlab paths


os.path.join() is your friend

Python paths


And there are likely similar functions in lots of other programming languages and statistical software.

Take away

Be aware of and always use the platform independent coding of paths, either a function or using “/”. NEVER use “\”.