STATA

Since STATA is one of the program I use, I list here how I organize my files and clean the data.

Organizing a dofile

In your dofile create "global" variables where you store all the path you will need. This is important if you work on different computers. This way you only have to change the global variables if you switch computer.

clear
set more off

global MainPath "C:\user\MyName\" // You would only change this global variable when switching computers
global Table "$MainPath\Table\"
global OriginalData "$MainPath\OriginalData\
...

cd "$MainPath/OutputFolder" // Set the working directory where you wish to save anything by default (i.e. when you don't specify a path)

Importing data

Depending on the format, you can use the following commands:
*** stata file (.dta)
use "$OriginalData\my_dataset.dta", clear

*** csv file (.csv)
insheet using "$OriginalData\my_dataset.csv", clear [options] // see "help insheet" for the [options]

*** excel file (.xls)
import excel using "$OriginalData\my_dataset.xls", clear [options] // see "help import excel" for the [options]

Exporting data

Depending on the format, you can use the following commands:
*** stata file (.dta)
save "my_dataset.dta", replace // to save the entire dataset // (see the custom function "savesome" if you want to save only certain variables)

*** csv file (.csv)
outsheet using "my_dataset.csv", replace [options] // see "help outsheet" for the [options]

*** excel file (.xls)
export excel using "$OriginalData\my_dataset.xls", replace [options] // see "help export excel" for the [options]