Thursday, December 30, 2010

Finding your way around Stata

One of the things my students first get stuck on is how to find things (e.g. files, directories, variables with particular labels or notes) in Stata.
There are a lot of commands to find things like files/datasets, directories, command help documentation, user commands/ado-files, variables, values, notes/chars, etc -- there are some commands that find only one of these things, some commands can find several of these things, and most of these things can be found by more than one command.  It can be a bit overwhelming and confusing and I've found that students who fall behind early in a class using Stata often get stuck at the point of being able to find these things -- particularly directories and command ado/help files.

Of course good use of a search engine is a key resource, but the table below gives an overview of the commands I use to find these things in Stata (this table can also found in my Module 1 Lecture for PHPM 672).    Undoubtedly, there are other commands that will do these tasks, but these are the ones that stuck with me after I started using them.

[Note:  You may need to widen your browser window or right click and open/download the image below in a new tab in order to view all 3 columns]

[note:  example for ":dir" should look for the pattern "*.dta", not ".dta" in order to find all .dta files in a directory]

BTW, see this Statalist posting by NJC about -findname- vs. -ds-

Another useful tool for finding these things is the new(ish) "Variables Manager" (introduced in Stata 11 -- see image below).  Type -varman- in the command window or Command+7 (in Mac Stata 11) to activate it.  

The Variables Manager allows you to quickly view and edit variable & value labels, formats, notes, and chars as well as search/filter results on the fly using the search box.  You can copy and paste the resulting variable list to your command window or do-file editor.  

No comments:

Post a Comment