Nov 1, 2011

10 Things every Beginner should know about Stata

When I first started working with Stata my initial impression was that it was ugly, and overwhelming.  I was confused as to why you would want to type in commands rather than point and click (this became painfully obvious over time). This was because I had transitioned from Microsoft Excel. Of course, the two programs while sharing some functionality are hardly comparable.

What I have come to find is that the Stata and excel are built for different types of work. Excel is for data entry, simple data manipulation, and record keeping. Stata is for statistics, and statistical programming.

I should mention that I did not learn Stata starting from page one of the manual. Rather, I picked it up as I went along, through google searches, and using #1 from below.

I am by no means an expert - but having worked with Stata for over a year now I believe I've found a few things that I wish I could have discovered on my first week using Stata. Hopefully if your a beginner or intermediate Stata user, you'll find this list to be helpful! If your looking for a good place to start, I have highlighted four websites where you can start learning stata here.
  1. Type help followed by a command and Stata will bring up a help file or do a keyword search. For example, try typing in help correlate. This makes learning Stata easy and referencing proper usage of commands easier than using dialogues at times.
  2. Stata is extensible. Type findit and Stata will search repositories for programs. There are programs for everything from reversing the order of labels to producing a latex table of regression output
  3. Do Files: These are text files ending with the .do extension. that are nothing generally contain a list of commands and comments you create. You can use them to keep track of what you have done to a dataset (by successively adding newly typed commands), or create scripts for repetitive tasks. Read more >>
  4. When I first started many of my struggles were in getting Stata to do something that was trivial in excel. For instance sorting in reverse alphabetical order (see gsort) or splitting city-state references (see split). The following are a few of the data manipulation commands that I use often. Use help to find out more if you don't know about one already.
    1. sort
    2. gsort
    3. order
    4. split
    5. drop
    6. generate
  5. Snapshots: In Stata you can save snapshots of your data. Unlike a program like Microsoft Excel, Stata doesn't include an undo button. Snapshots allow you to save your data at particular stages to return to in case you screw something up. For instance, I often create a snapshot prior to merging two datasets in case a merge doesn't work. Snapshots can be created using the command snapshot or in more recent versions there is a tab on the lefthand side of the data editor for creating them.
  6. Snapshots can be created using the 'snapshot' tab on the lefthand side.
  7. _n, and _N: These are system variables. _n is a variable for the current observation (row) being worked with. If you were to type generate newvar = _n, you would get a variable numbed 1 through the number of rows you have. _N is a variable for the total number of rows in your dataset. Tutoral: Using _n and _N in Stata >>
  8. Subscripting: This allows you to reference individual elements or observations of a variable. For instance, typing display var[3] will return the value of var found in the third row. Read More >>
  9. Macros: Macros are bits of data that can be saved and reused. For instance, macros allow you to temporary create variables, retrieve labels, incorporate them into commands, or they can be used as variables. Read More >>
  10. Return List: If you use Statas built in commands it won't always output everything your looking for or a truncated p-value. You can retrieve more accurate numbers by typing return list following a command to see what data Stata makes available. Tutorial: Using the Return List in Stata >>
  11. Loops and branching: You can use if, while, and looping statements in Stata to automate all kinds of tasks in Stata. See the following for more:

2 comments:

  1. Download STATA 15 Full Version
    https://www.youtube.com/watch?v=3Wf1yLV6668
    This Video Provides Download Links To Software STATA 15. It is Software STATA 15 Full Version. Thank You for See Video Download STATA 15 Full Version

    ReplyDelete