Skip to content
Home » Stata Do File initialization

Stata Do File initialization

Remembering what that Do file is for !

I have lost count of how often did I get confused when revisiting a DO file couple of months later ?  Gradually, I have developed the following as a method of minimizing the confusion –

cd "D:\Work\ProjectName\DataDirectory" capture log close log using "results1.smcl", replace use "Data1.dta", clear save "Data2.dta", replace //Immediately Save to Avoid overwriting original data cls // DATE CREATED: // PURPOSE // DATE UPDATED: // EDITS DONE: ************ DATA MANAGEMENT *********** **************************************** save "Data2.dta", replace cap log close view "results1.smcl"
Code language: JavaScript (javascript)

I think its quite obvious. Still what were are doing is:

  1. Entering our work directory
  2. Closing any open LOGs
  3. Opening a new LOG file
  4. Opening a Data File and IMMEDIATELY saving it as NEW data file.
  5. Clearing output screen
  6. Stating initial purpose of file with date. A couple of sentences go a long way in the long run
  7. Adding dates that the file was edited after initial freezing and the purpose of edits. Maintining Audit trail is vital.
  8. Do the Data management / Analysis
  9. Save the Data file
  10. Close the Log file and view the logs