Why does pressing Return after clicking on a variable in the Variables
window sometimes output the variable twice?
How to avoid outputting the variable twice
Chinh Nguyen, StataCorp
July 2007; updated February 2008
Stata 10 now uses the Data Browser control for the Variables window. This is
the same control the Finder uses for displaying files in in list form in a
folder window. The Data Browser behaves differently depending on where you
click in the control.
To explain this, let’s look at two scenarios.
- If you click a variable name in the Variables window, the
Data Browser selects the cell containing the variable name and causes
Stata to output the variable name to the Command window. The keyboard
focus is then set to the Command window forcing the Command window to
stay in front. Pressing the spacebar will not output the variable name
again because the focus is not the Variables window.
- If you click a blank area of a cell that contains a variable name,
then the Data Browser sets the keyboard focus to the Variables window and
moves it to the front. When we say blank area, we are referring to any
area in the cell that does not contain the variable name such as the
format or label. Pressing the spacebar will output the variable name
again because the focus is on the Variables window. Stata cannot
prevent this from happening because this behavior is imposed by Mac OS
The Data Browser controls also allow keyboard navigation of the list in the
control. Thus you can use keyboard navigation once the focus is set to the
Variables window. A few of the keyboard navigations are as follows:
- Pressing the cursor up and down keys will navigate the list while
changing which variable name is highlighted.
- Pressing the spacebar while a variable name is highlighted outputs the
variable name to the Command window while leaving the focus on the
- Pressing Return while a variable name is highlighted outputs the
variable name, sets the keyboard focus to the Command window, and
enters the command in the Command window into Stata.
The reason a variable may show up twice after pressing Return is because you
clicked a blank area of a cell containing a variable name and then
pressed Return. This sequence outputs the variable name into the Command
window, sets the keyboard focus to the Variables window, and enters the
variable name again once Return is pressed.
To avoid this behavior, you must click a variable name in the Variables
window, not a blank area.