Run STATA in VScode - wulizyk/Notebook_Stata GitHub Wiki

Besides ST3 (Sublime Text 3), VScode (Visual Studio Code) is another cool code editor (actually a better one) to write programs.
You can easily pick up, browse, edit and run various types of files, which helps you smoothly change between files with different syntaxes, such as Matlab (.m), python (.py), stata (.do).
There are two ways (WAY ONE and WAY TWO) to run STATA (do file)in VScode, but I can only adopt the first way.
Lastly, I would like to post some hiccups when exercising WAY TWO.


3.1 Stata Enhanced plugin (easy)
3.2 Rundolines and Rundo

These two zips are downloaded from Friedrich Huebler's blog, and they are compatible with STATA16 and STATA17.

  1. rundo51.zip
  2. rundolines51.zip

[IMPORTANT] unzip and place these two folders under E:\Stata17\ado\personal (this is my path, you can put them anywhere, but DON'T let your path has spaces. I first used C:\Program Files\Stata17\ado\personal\rundo51, but VScodes gave me an error T-T due to the space between Program and Files).

3.3 Code Runner (pls follow me to get the .json file and modify it) WeChat Screenshot_20220408015719 You need to know where these .exe files are. WeChat Screenshot_20220408020044

3.4 Operation The default shortcut keys are ctrl+alt+N (run the entire file) and ctrl+alt+K (run the selected code, not the ctrl+D).


  • WAY TWO: Based on runStata plugin + stata-exec (Failed T-T)
    Here I would like to provide some tips though, pls tell me if you figure it out.\
  1. installation: runStata and Node
  2. installation: stataRun WeChat Screenshot_20220408020847 The version is not the same as the author's, pls be cautious.
    And, see stataRun_VScode_Marketplace, but I got errors running npm install winax --python=%USERPROFILE%\.windows-build-tools\python27\python.exe in cmd T-T.

  • Finally (^-^) WeChat Image_20220408022120

Others:

  1. Choose the whole line you wanna run!! (unlike stata which can automatically run the line with partially chosen.)
  2. You can modify the keyboard: file >> preference >> keyboard shortcut >> the default is ctrl+alt+k, you can change to alt+D

VScode with Python
VScode with R The path should be added like in my PC, it should be " E:\python_all\R\R-3.6.3\bin "

Unfinished:
VScode with LATEX