Using the Stata Viewer

The Viewer’s purpose

The Viewer is a versatile tool in Stata. It will be the first place you can turn for help within Stata, but it is far more than just a help system. You can also use the Viewer to add, delete, and manage third-party extensions to Stata that are known as community-contributed features; to view and print Stata logs from both your current and your previous Stata sessions; to view and print any other Stata-formatted (SMCL) or plain-text file; and even to launch your web browser to follow hyperlinks.

This chapter focuses on the general use of the Viewer, its buttons, and a brief summary of the commands that the Viewer understands. There is more information about using the Viewer to find help in [GSW] 4 Getting help and for installing community-contributed features in [GSW] 19 Updating and extending Stata—Internet functionality.

To open a new Viewer window (or open a new tab in an existing Viewer), you can either click on the Viewer button,  , or select Window > Viewer > New Viewer.

Viewer buttons

The toolbar of the Viewer has multiple buttons, a command box, and a search box.

The Find bar is used to find text within the current Viewer. To reveal the Find bar at the bottom of the window, click on the Find text in page button:

The Find bar has its own buttons, fields, and checkboxes.

Viewer’s function

The Viewer is similar to a web browser. It has links (shown in blue text by default) that you can click on to see related help topics and to install and manage third-party software. When you move the mouse pointer over a link, the status bar at the bottom of the Viewer shows the action associated with that link. If the action of a link is help logistic, clicking on that link will show the help file for the logistic command in the Viewer. Middle-clicking on a link in a Viewer window (Ctrl+clicking if you do not have a three-button mouse) will open the link in a new tab in the Viewer window. Shift+clicking will open the link in a new Viewer window.

You can open a new Viewer by selecting Window > Viewer > New Viewer or by clicking on the Viewer button on the toolbar of the main window. Entering a help command from the Command window will also open a new Viewer.

To bring a Viewer to the front of all other Viewers, select Window > Viewer and choose a Viewer from the list there. Selecting Close all Viewers closes all open Viewer window and tabs.

Viewing local text files, including SMCL files

In addition to viewing built-in Stata help files, you can use the Viewer to view Stata Markup and Control Language (SMCL) files such as those typically produced when logging your work (see [GSW] 16 Saving and printing results by using logs) as well as plain-text files. To open a file and view its contents, simply select File > Open…, and you will be presented with a dialog:

You may either type in the name of the file that you wish to view and click on OK, or you may click on the Browse… button to open a standard file dialog that allows you to navigate to the file.

If you currently have a log file open, you may view the log file in the Viewer. This method has one advantage over scrolling back in the Results window: what you view stays fixed even as output is added to the Results window. If you wish to view a current log file, select File > Log > View…, and the usual dialog will appear but with the path and filename of the current log already in the field. Simply click on OK, and the log will appear in the Viewer. See [GSW] 16 Saving and printing results by using logs for more details.

Viewing remote files over the Internet

If you want to look at a remote file over the Internet, the process is similar to viewing a local file, only instead of using the Browse… button, you type the URL of the file that you want to see, such as https://www.stata.com/man/readme.smcl. You should use the Viewer only to view text or SMCL files. If you enter the URL of, say, an arbitrary webpage, you will see the HTML source of the page instead of the usual browser rendering.

Navigating within the Viewer

In addition to using the scrollbar to navigate the Viewer window, you also can use the up and down arrow keys and Page Up and Page Down keys to do the same. Pressing the up or down arrow key scrolls the window a line at a time. Pressing the Page Up or Page Down key scrolls the window a screen at a time.

Printing

To print the contents of the Viewer, right-click on the window and select Print…. You may also select File > Print > Viewer name or click on the Print toolbar button, , to print.

Tabs in the Viewer

A Viewer window can have multiple tabs. You may view different files or different views of the same file in different tabs. Clicking on the Open new tab button, +, will open a new tab in the current Viewer window. You can change the order of the tabs within a Viewer by dragging the tabs along the tab bar within the window. If you drag a tab and drop it within the body of the same Viewer window, a menu will appear. If you select New Horizontal Tab Group, the Viewer window will be split horizontally. This is useful for having two views of the same file at different places in the file. Similarly, if you select New Vertical Tab Group, the Viewer window will be split vertically. This is useful for comparing two similar files side by side.

Once you have created a horizontal or vertical tab group, if you drop a tab inside a group, you will get the choice of creating a similar new group or moving the tab to the selected group.

Right-clicking on the Viewer window

Right-clicking on the Viewer window displays a contextual menu that offers these options:

  • Select all to select all text in the Viewer.
  • Preferences .. to edit the preferences for the Viewer window.
  • Font .. to change the font for the window.
  • Print.. to print the contents of the Viewer window.

In other contexts, there could be more items displayed in the contextual menu.

Searching for help in the Viewer

The search box in the Viewer can be used to search documentation. Click on the magnifying glass; choose Search all, Search documentation and FAQs, or Search net resources; and then type a word or phrase in the search box and press Enter. For more extensive information about using the Viewer for help, see [GSW] 4 Getting help.

Commands in the Viewer

Everything that can be done in the Viewer by clicking on links and buttons can also be done by typing commands in the command box at the top of the window or on the Stata command line. Some tasks that can be performed in the Viewer are

  • obtaining help (see [GSW] 4 Getting help):

Type contents to view the contents of Stata’s help system.

Type commandname to view the help file for a Stata command.

Type keyword to search documentation, FAQs, and net resources for a topic.

  • searching (see [GSW] 4 Getting help):

Type search keyword to search documentation, FAQs, and net resources for a topic. Type search keyword, local to search only documentation and FAQs for a topic.

Type search keyword, net to search only net resources for a topic.

  • finding and installing community-contributed commands (see [GSW] 4 Getting help and [GSW] 19 Updating and extending Stata—Internet functionality):

Type net from https://www.stata.com/ to find and install Stata Journal, Stata Technical Bulletin, and community-contributed commands from the Internet.

Type ado to review community-contributed packages you have installed.

Type ado uninstall to uninstall community-contributed packages you have installed on your computer.

  • viewing files in the Viewer:

Type view filename.smcl to view SMCL files.

Type view filename .txt to view text files.

Type view filename .log to view text log files.

  • viewing files in the Results window:

Type type filename.smcl in the Command window to view SMCL files in the window.

Type type filename .txt in the Command window to view text files in the window.

Type type filename .log in the Command window to view text log files in the window.

  • launching your browser to view an HTML file:

Type browse URL to launch your browser.

Using the Viewer from the Command window

Typing help commandname in the Command window will bring up a new Viewer showing the requested help.

Source: STATA (2021), Getting Started with Stata for Windows, Stata Press Publication.

Leave a Reply

Your email address will not be published. Required fields are marked *