*Stata versions version 13 *Add a header to your do file ********************************************* * Project Title: * * Description: * * Datasets used: * * Author: * ********************************************* *Use relative paths //Absolute paths use "E:\\Stata\Project1\data1.dta",clear merge 1:1 symbol using "E:\\Stata\Project1\example\data2.dta" //Relative paths //Method 1: Use change directory command cd "E:\\Stata\Project1\" use "data1.dta",clear merge m:1 symbol using "example\data2.dta" //Method 2: Use global variables global path "E:\\Stata\Project1\" use "$path\data1.dta",clear merge m:1 symbol using "$path\example\data2.dta" *Stata don't mind spaces and indentation //Wrong way forvalues i=1/10 { display `i' } //Right way forvalues i=1/10 { display `i' } *More option set more off set more off,permanently *Master do files do "1.unziprawfiles.do" do "2.stockdata.do" do "3.sectordata.do" do "4.indexdata.do" do "5.announcements.do" //Single do file can call upto 1000 other do files and 64 level nested. *Log files log using "example.smcl" *Stand alone do files //e.g. loading the dataset to do file automatically *Grouping commands generate abc= 1 generate abcdef= 2 rename abc newabc rename abcdef newabcdef *Dont abbreviate too much generate abc=1 gen abc=1 g abc=1 *Different file names for input and output *Closing log file capture: log close capture { } *Organizing the folder *Numbering the do files *Commenting the do file //consistent commenting style *Consistency in variable name and lables //not necessary to label at start of the project *Quietly use "Quietly" quietly: write your command here