{"id":450,"date":"2020-06-19T14:18:55","date_gmt":"2020-06-19T18:18:55","guid":{"rendered":"http:\/\/blog.uvm.edu\/tbplante\/?p=450"},"modified":"2020-09-16T09:47:19","modified_gmt":"2020-09-16T13:47:19","slug":"making-a-new-blank-stata-do-file-within-windows-explorer","status":"publish","type":"post","link":"https:\/\/blog.uvm.edu\/tbplante\/2020\/06\/19\/making-a-new-blank-stata-do-file-within-windows-explorer\/","title":{"rendered":"Making a new, blank Stata do file within Windows Explorer"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Simplify your do file creation! <\/h2>\n\n\n\n<p>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. <\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:75% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"784\" height=\"568\" src=\"https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/new-do-file.png\" alt=\"\" class=\"wp-image-453\" srcset=\"https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/new-do-file.png 784w, https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/new-do-file-300x217.png 300w, https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/new-do-file-768x556.png 768w\" sizes=\"auto, (max-width: 784px) 100vw, 784px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\"><\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Why is something like this useful?<\/h2>\n\n\n\n<p>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: <strong>It sets the working directory as the folder that the do file is in<\/strong>. For example, if your do file here:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">C:\\users\\MYID\\research\\BP_project\\project.do<\/pre>\n\n\n\n<p>Double clicking that do file in Windows Explorer to open up a new Stata session will set your working directory as:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">C:\\users\\MYID\\research\\BP_project\\<\/pre>\n\n\n\n<p>Now let&#8217;s say you have a subfolder with your data here:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">C:\\users\\MYID\\research\\BP_project\\data\\baseline.dta<\/pre>\n\n\n\n<p>Since Stata has set your working directory as &#8220;C:\\users\\MYID\\research\\BP_project\\&#8221;, all you need to type to open this dataset is:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">use data\\baseline.dta, clear<\/pre>\n\n\n\n<p>This is great because now you can move around your research folder and not worry about your new directory tree being different. <\/p>\n\n\n\n<p>Currently, the only way to make a new Do file is from <em>within <\/em>Stata&#8217;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 &#8220;new file&#8221; menu in Windows Explorer, you can just right-click your research folder and make a blank do file with your desired name. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to do this?<\/h2>\n\n\n\n<p>Full disclosure, this is a modification of a blog post that I found <a href=\"https:\/\/www.howtogeek.com\/290500\/how-to-add-other-file-types-to-the-new-item-menu-in-windows-10s-file-explorer\/\">here on howtogeek.com written by Lori Kaufman<\/a>. You need to have administrator privileges to do this, btw. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Open the registry editor from the start menu<\/h3>\n\n\n\n<p>Hit the Start button then type &#8220;regedit&#8221;. <\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:72% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"976\" height=\"825\" src=\"http:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-1.png\" alt=\"\" class=\"wp-image-458\" srcset=\"https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-1.png 976w, https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-1-300x254.png 300w, https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-1-768x649.png 768w\" sizes=\"auto, (max-width: 976px) 100vw, 976px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\"><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2:  Navigate to HKEY_CLASSES_ROOT &#8211;&gt; .do <\/h3>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:65% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"381\" height=\"296\" src=\"http:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-2.png\" alt=\"\" class=\"wp-image-459\" srcset=\"https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-2.png 381w, https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-2-300x233.png 300w\" sizes=\"auto, (max-width: 381px) 100vw, 381px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\"><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Right-click the .do folder and make a new Key<\/h3>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:73% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"594\" height=\"339\" src=\"http:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-3.png\" alt=\"\" class=\"wp-image-460\" srcset=\"https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-3.png 594w, https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-3-300x171.png 300w\" sizes=\"auto, (max-width: 594px) 100vw, 594px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\"><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Name that key &#8220;ShellNew&#8221;<\/h3>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:62% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"249\" height=\"132\" src=\"http:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-4.png\" alt=\"\" class=\"wp-image-455\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\"><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: In the ShellNew key, make a new String Value<\/h3>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:67% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"579\" height=\"192\" src=\"http:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-5.png\" alt=\"\" class=\"wp-image-456\" srcset=\"https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-5.png 579w, https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-5-300x99.png 300w\" sizes=\"auto, (max-width: 579px) 100vw, 579px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\"><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Name it &#8220;FileName&#8221;<\/h3>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:67% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"394\" height=\"157\" src=\"http:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-6.png\" alt=\"\" class=\"wp-image-457\" srcset=\"https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-6.png 394w, https:\/\/blog.uvm.edu\/tbplante\/files\/2020\/06\/step-6-300x120.png 300w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\"><\/p>\n<\/div><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Close the registry editor<\/h3>\n\n\n\n<p>That&#8217;s it! It&#8217;d be nice for this to be built in with Stata in a future version. Enjoy!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 &hellip; <a href=\"https:\/\/blog.uvm.edu\/tbplante\/2020\/06\/19\/making-a-new-blank-stata-do-file-within-windows-explorer\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Making a new, blank Stata do file within Windows Explorer<\/span><\/a><\/p>\n","protected":false},"author":4473,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-450","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/posts\/450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/users\/4473"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/comments?post=450"}],"version-history":[{"count":6,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/posts\/450\/revisions"}],"predecessor-version":[{"id":577,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/posts\/450\/revisions\/577"}],"wp:attachment":[{"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/media?parent=450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/categories?post=450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/tags?post=450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}