------------------------------------------------------------------------------------ log: c:\stata\carsdata.txt log type: text opened on: 16 Jan 2009, 15:11:58 . . * Read in the Stata data set carsdata.dta . use carsdata.dta . . * Describe the variables in the data set . describe Contains data from carsdata.dta obs: 5 vars: 2 16 Jan 2009 10:47 size: 50 (99.9% of memory free) ------------------------------------------------------------------------------------ storage display value variable name type format label variable label ------------------------------------------------------------------------------------ cars byte %8.0g Number of cars hhsize byte %8.0g Number of people in household ------------------------------------------------------------------------------------ Sorted by: . . * List the dataset . list +---------------+ | cars hhsize | |---------------| 1. | 1 1 | 2. | 2 2 | 3. | 2 3 | 4. | 2 4 | 5. | 3 5 | +---------------+ . . * Provide summary statistics of the variables in the data set . summarize Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- cars | 5 2 .7071068 1 3 hhsize | 5 3 1.581139 1 5 . . * Provide an X,Y scatterplot with a regression line . twoway (scatter cars hhsize) (lfit cars hhsize) . . * Save the preceding graph in a file in PNG (portable networks graphic) format . graph export carsdata.png, replace (file carsdata.png written in PNG format) . . * Regress cars on hhsize . regress cars hhsize Source | SS df MS Number of obs = 5 -------------+------------------------------ F( 1, 3) = 12.00 Model | 1.6 1 1.6 Prob > F = 0.0405 Residual | .4 3 .133333333 R-squared = 0.8000 -------------+------------------------------ Adj R-squared = 0.7333 Total | 2 4 .5 Root MSE = .36515 ------------------------------------------------------------------------------ cars | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- hhsize | .4 .1154701 3.46 0.041 .0325228 .7674772 _cons | .8 .3829708 2.09 0.128 -.4187841 2.018784 ------------------------------------------------------------------------------ . . end of do-file . exit, clear