Stata Keyboard Shortcuts
One useful shortcut is that Stata has repurposed some of your function keys to save time in running basic commands.
F1 opens the help advice window
F2 runs describe
F7 prints save
in the command window.
F8 prints use
in the command window.
You can assign whatever command you like to the function keys either per session or for all sessions. To redefine a function key type global [Fkey] "new command text"
You can add a space after the command, which will mean one less space you have to type after you press the F key in question. For example global F3 "ttest "
would print the command ttest
so all I had to type were the variables that followed. Similarly, a semicolon tells Stata to execute the command. For example global F7 "save, replace;"
would over-write the old definition of F7 as printing the word save
so if you pressed F7, Stata would save the current data set over the previously existing copy without requiring any further user input. To make a preference stick from session to session, you can add the global commands to Stata's startup sequence (see here for instructions).
There are three keys that have set functions. The "page up" key scrolls back through previous commands at a rate of one command per press and prints the command in the Command window, and the "page down" key does the reverse. The "esc" key clears the contents of the Command window without executing them.
Another useful keyboard shortcut Stata offers is tab completion on variable names. If you type the first few letters of a variable name while inputting a command and then press the tab key, Stata will fill in the rest. If there is ambiguity (for example dateofprom, dateofdress) and you type in a few characters (corr dat) then press "tab", Stata will fill in letter until the ambiguity (corr dateof) - and if I were to then type "p" (corr dateofp) I could hit tab once more and get corr dateofprom. You can also click on the arrow next to a variable in the Variables window to add it to the Command window.
Back to Tutorials