Search
   >> Home >> Resources & support >> FAQs >> How to avoid outputting the variable twice

Why does pressing Return after clicking on a variable in the Variables window sometimes output the variable twice?

Title   How to avoid outputting the variable twice
Author Chinh Nguyen, StataCorp
Date 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.

  1. 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.
  2. 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 X.

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:

  1. Pressing the cursor up and down keys will navigate the list while changing which variable name is highlighted.
  2. Pressing the spacebar while a variable name is highlighted outputs the variable name to the Command window while leaving the focus on the Variables window.
  3. 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.

The Stata Blog: Not Elsewhere Classified Find us on Facebook Follow us on Twitter LinkedIn Google+ Watch us on YouTube