Skip to content

Instantly share code, notes, and snippets.

@DrGo
Last active March 17, 2018 17:41
Show Gist options
  • Save DrGo/dd640831bd779547730f2ba061923232 to your computer and use it in GitHub Desktop.
Save DrGo/dd640831bd779547730f2ba061923232 to your computer and use it in GitHub Desktop.
Bringing up the variable manager window while using Stata command line

If you are like me, when you are using Stata's command window you do not like to switch to using the mouse to bring up the variable manager window whenever, e.g., you want to check the name of a variable.

One solution is assigning the following commands to a certain function key (e.g., F2) and running it every time you load Stata by adding it to your profile.do file.

global F2 : display "varm" _char(13) "sleep 1000" _char(13) "window manage forward command;"

Everytime you press F2, the variable manager window will be displayed for 1 second.

How it works

display is special macro function that converts its argument to a Stata string. I am passing it three separate commands, so each commands is followed by "_char(13)" directive which inserts a carriage return in the returned string (akin to pressing the enter key after typing each command). The first command "varm" brings up the variable manager window. The second "sleep 1000" waits for 1 sec (1000 milliseconds) before executing the last command which activates the command window so I could continue typing without interruption. The semicolon at the end aslo functions as an instruction to execute the command. Try removing it and see what happends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment