This brief reference is just to remind you of the basic commands you will use for this class. State has very good on-line help, just type help command or use the search button. |
Action | Stata command |
| To open a log file: | log using filename.log |
| To close the currently open log file: | log close |
| To open Stata data set: | use dataset.dta |
| To open ascii data set: | insheet using dataset.asc |
| To view means and variances of variables: | summarize |
| To create a new variable: | generate varname=value |
| To change values of an old variable: | replace varname=new value |
| To change specific values of an old variable: | replace varname=new value if varname= =value |
| To generate a random uniform variable: | generate varname=uniform() |
| To generate a random binary variable: | generate varname=round(uniform(),1) |
| To set the number of observations: | set obs number |
| To tabulate one variable: | table varname |
| To tabulate one variable against another: | table rowvar colvar |
| To graph a histogram of one variable with k possible values: | graph varname, bin(k) |
| To conduct a difference in means test between two variables: | ttest varname1 varname2 |
| To conduct a difference in means test for one variable (split by varname2): | ttest varname1, by(varname2) |
| To run a regression of a dependent variable on independent variables: | regress depvar indvar1 indvar2 ... indvarK |