Unformatted text preview:

Stata 1 Stata Popular program in Economics, Medicine, ??? The previous versions were command line based. The current version (8) has switched to more of a graphical menu driven interface. However, everything can be done from a command line. Somethings have to be done from the command line. Has very good Survey Sampling routines More of a canned program, though you can write your own routines, and even link in your own C code (with version 8.1). While you can do some programming with it, and a lot of people apparently do, I would not use Stata unless I was performing a “standard” analysis. Use S-Plus/R in those situations. Has excellent backward compatibility with previous versions Available for Windows, Macintosh, Unix (not available at Harvard that I can find).Stata 2 The default setup will look similar to the above. However you can change the setup, font sizes, colours, etc. These will be kept from session to session.Stata 3Stata 4Stata 5 Data Input: Stata can only deal with two file formats, its own, and text files for data. Its own file format has changed over time, but the current versions can read older versions. However the other way doesn’t work (e.g. Version 7 can read a version 8 file)Stata 6 Reading in text files insheet using "C:\Documents and Settings\Irwin\My Documents\Harvard\Courses\Stat 104\93cars.txt", clear When creating commands with Stata, the command you would need to type is given in the Results window and the Review window. The Review window can be used to either repeat commands (double click on the command) or as a start to create a new command (single click). A single click will put the command into the Commands window and it can be edited Also the previous version of a command is kept in the dialogue boxes so you can also edit things that way as well.Stata 7 The button in a command dialogue box will clear the entries. The underlying data structure is similar to a Spreadsheet. Rows correspond to observations and colums correspond to variables. You can also think of it like a S-Plus/R data frame. In Stata you can only have one data file in use at a time. Its not like S-Plus/R where you can have many data frames available. It is possible to combine datasets to get around this limitation. All you can really read in is a table with r rows and c columns. However the columns can be a mixture of numbers and strings. Just about any file that read.table() will work with, the Stata insheet command can handle. . insheet using "filename.raw", clear The default file extension for text files being read in is .raw, though any can be used. The clear option is there to force the current data file to be deleted from memory and to be replace by the new file. If not, you will get an error message similar toStata 8 insheet using "Berkeley.txt" you must start with an empty dataset r(18); While the expected column separators are either commas or tabs, any character can be used. Exporting Data outsheet using " Berkeley.raw", replace outsheet using " Berkeley-men.raw" if gender == "Men", replaceStata 9 Defining variables Going through the dialogues will generate a command like generate float CityFuel= 100/HighMPG generate float CityFuel= 100/CityMPG HighFuel already definedStata 10 generate can only be used for creating a variable for the first time. If you need to update a variable use replace replace CityFuel= 100/CityMPG (93 real changes made) Stata has the property when creating a new variable to place results in every row, even when it may not make intuitive sense. For example generate tcrit= invttail(24,0.025) will place the value 2.063899 in every row of the data file. To store it only in the first row, use gen tcrit= invttail(24,0.025) in 1 instead. Actually for this sort of calculation, you probably just want disp invttail(24,0.025) 2.0638985 which just prints the result in the Results window.Stata 11 Viewing Data There are a number of ways that you can view your data in Stata. The first is the list command list MinPrice MidPrice MaxPrice in 1/10, separator(5) +--------------------------------+ | MinPrice MidPrice MaxPrice | |--------------------------------| 1. | 12.9 15.9 18.8 | 2. | 29.2 33.9 38.7 | 3. | 25.9 29.1 32.3 | 4. | 30.8 37.7 44.6 | 5. | 23.7 30 36.2 | |--------------------------------| 6. | 14.2 15.7 17.3 | 7. | 19.9 20.8 21.7 | 8. | 22.6 23.7 24.9 | 9. | 26.3 26.3 26.3 | 10. | 33 34.7 36.3 | +--------------------------------+ The other common approaches are with the Data Editor (edit) and the Data Browser (browse)Stata 12 They both appear the same, but only with the Editor can you make changes. Also when either of these is active, it is not possible to run any analyses. You must close the window to proceed. With the data editor, you cannot give variable names within the editor. However you can change them later with the rename command, e.g. rename Manu Manufacturer Also many command names can be abbreviated. For example you can use ren for rename, reg for regress, etc.Stata 13 To see what they are, check the help pages. They can be displayed in the main results window, with a command like help regress or in Stata Viewer window (which you get if you click on the help button in the dialogue box) The help facility isn’t bad. One nice features is that it uses hyperlinks, allowing you to immediately go to another help page of interest.Stata 14 Graphics The quality of the graphs is ok. The resulting graphs are somewhat configurable (fonts, colours, etc), but there are some limitations. For the common graphs, scatter plots, bar charts, etc, there are two approaches through the menus; Easy graphs and main menu entry. The Easy graph dialogue boxes are a bit friendlier, but are not as powerful (missing options).Stata 15 Easy Graph approach to a bar chart Main approach to a bar chartStata 16 Both approaches could yield the command graph bar (sum) count, over(major) ytitle(# Applications) title(Berkeley Grade School Applications in 1973) 0 200 400 600 800 1,000# ApplicationsA B C D E FBerkeley Grade School Applications in 1973 One drawback in the Stata approach to graphics is that you can’t add onto figures, as with S-Plus/R and Matlab. However you can create figures that overlay plots on


View Full Document

HARVARD STAT 335 - Stata

Documents in this Course
Load more
Download Stata
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Stata and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Stata 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?