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.
- WAY ONE: Based on Stata Enhanced + Code Runner plugin (Successfully done)
Please follow steps written by Edit and run stata's do-file in VS Code (in English) or vsCode+Stata:在 VScode 中编辑和运行Stata命令 (in Chinese). They also post images, so no worry.
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.
[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)
You need to know where these .exe files are.
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.\
- installation: runStata and Node
- installation: stataRun
The version is not the same as the author's, pls be cautious.
And, see stataRun_VScode_Marketplace, but I got errors runningnpm install winax --python=%USERPROFILE%\.windows-build-tools\python27\python.exe
in cmd T-T.
- Finally (^-^)
Others:
- Choose the whole line you wanna run!! (unlike stata which can automatically run the line with partially chosen.)
- 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