Simplify your do file creation!
I figured out how to add Stata Do-Files to the list of new files to create on the right-click menu within Windows explorer! Now you can create a blank Do file from within Windows Explorer. I hope Stata decides to build this into future versions. This is incredibly helpful.
Why is something like this useful?
I do 99% of my Stata work from within do files. There is one huge advantage to opening up Stata by clicking on a do file within Windows Explorer: It sets the working directory as the folder that the do file is in. For example, if your do file here:
Double clicking that do file in Windows Explorer to open up a new Stata session will set your working directory as:
Now let’s say you have a subfolder with your data here:
Since Stata has set your working directory as “C:\users\MYID\research\BP_project\”, all you need to type to open this dataset is:
use data\baseline.dta, clear
This is great because now you can move around your research folder and not worry about your new directory tree being different.
Currently, the only way to make a new Do file is from within Stata’s Do file editor. This means you need to open Stata, open the Do File Editor, save a blank Do file in the desired folder, close Stata, then double click on the new Do file to re-open Stata with the correct directory as the working directory. By adding it to the “new file” menu in Windows Explorer, you can just right-click your research folder and make a blank do file with your desired name.
How to do this?
Full disclosure, this is a modification of a blog post that I found here on howtogeek.com written by Lori Kaufman. You need to have administrator privileges to do this, btw.
Step 1: Open the registry editor from the start menu
Hit the Start button then type “regedit”.
Step 2: Navigate to HKEY_CLASSES_ROOT –> .do
Step 3: Right-click the .do folder and make a new Key
Step 4: Name that key “ShellNew”
Step 5: In the ShellNew key, make a new String Value
Step 6: Name it “FileName”
Step 7: Close the registry editor
That’s it! It’d be nice for this to be built in with Stata in a future version. Enjoy!