

Normal data with mean 0 and standard deviation 1:.(These commands simulate rolling a six-sided die): Generate n discrete uniform random variables (equal chance of all outcomes between 1 and 6.Generate n uniform random variables (equal chance of all outcomes between a and b:.Generate n uniform random variables (equal chance of all outcomes between 0 and 1:.Set random number seed to XXXX, default is 1000:.


A scatter plot of two variables with the values of a third variable used in place of points on the graph (vthr might contain numerical values or indicate categories, such as male (m) and female (f)):.A matrix of scatter plots for three variables:.Plot side-by-side box plots for one variable (vone) by categories of another variable vtwo.Plot a histogram of a variable with a normal approximation:.Plot a histogram of a variable using frequencies:.View the entire collection of UVA Library StatLab articles.Today I will teach you Common Stata Commands If you are working with a big dataset, you may not want to list too much information to your output. In this case, the census.dta is a small dataset with only 50 rows/observations in it, and I eliminated 33 observations so I know I only have a fairly small number of cases to be listed in the output. You may want to be careful when using the `list` command. * drop the rows/states with population less than the mean For example, we can keep the states in the South. We can also use -keep- and -drop- commands to subset data by keeping or eliminating observations that meet one or more conditions. So here I save it as a new file called slist. You may want to be careful when you save this change, as you will permanently lose all the other variables that are not in the keep list. Note that this change only applies to the copy of the data in the memory, not the file on disk – you need to use the -save- command to make change to the file itself. Now that you should only see the three variables remain in the data. Say we would like to have a separate file contains only the list of the states with the region variable, we can use the -keep- command to do so. Marriage long %12.0gc Number of marriages State2 str2 %-2s Two-letter state abbreviation Variable name type format label variable label Contains data from /Applications/Stata/ado/base/c/census.dta
