Univariate AnalysisCommands to use with continuous variables1. summarize2. graph box3. histogramExamples:. summarize age Variable | Obs Mean Std. Dev. Min Max-------------+------------------------------------------------------- age | 43541 45.21968 17.5268 18 89. summarize age, detail AGE OF RESPONDENT------------------------------------------------------------- Percentiles Smallest 1% 19 18 5% 22 1810% 24 18 Obs 4354125% 31 18 Sum of Wgt. 4354150% 42 Mean 45.21968 Largest Std. Dev. 17.526875% 58 8990% 71 89 Variance 307.188995% 77 89 Skewness .475271399% 86 89 Kurtosis 2.243301. graph box, title(“Boxplot”). histogram age, bin(20) title("histogram")20 40 60 80 100AGE OF RESPONDENTBoxplot0 .005 .01 .015 .02 .025Density20 40 60 80 100AGE OF RESPONDENThistogram1Commands to use with categorical variables1. summarize2. tabulate3. graph pie4. graph barExamples: . summarize female Variable | Obs Mean Std. Dev. Min Max-------------+------------------------------------------------------- female | 43698 .5616275 .4961932 0 1 . tabulate marital MARITAL | STATUS | Freq. Percent Cum.--------------+---------------------------------- MARRIED | 24,349 55.73 55.73 WIDOWED | 4,462 10.21 65.94 DIVORCED | 4,984 11.41 77.35 SEPARATED | 1,530 3.50 80.85NEVER MARRIED | 8,365 19.15 100.00--------------+---------------------------------- Total | 43,690 100.00. graph pie, over(marital) title("Pie Chart"). graph bar (count) id, over(marital) title("Bar Chart")MARRIED WIDOWEDDIVORCED SEPARATEDNEVER MARRIEDPie Chart0 5,000 10,000 15,000 20,000 25,000count of idMARRIED WIDOWED DIVORCED SEPARATEDNEVER MARRIEDBar Chart2Bivariate AnalysisCommands to use with 2 categorical variables1. tabulate2. graph pie3. graph barExamples:. tabulate sex premarRESPONDENT | IS PREMARITAL SEX WRONG? S SEX | ALWAYS WR ALMOST AL WRONG ONL NOT WRONG | Total-----------+--------------------------------------------+---------- MALE | 374 153 329 723 | 1,579 FEMALE | 689 275 389 776 | 2,129 -----------+--------------------------------------------+---------- Total | 1,063 428 718 1,499 | 3,708 . tabulate sex premar, row+----------------+| Key ||----------------|| frequency || row percentage |+----------------+RESPONDENT | IS PREMARITAL SEX WRONG? S SEX | ALWAYS WR ALMOST AL WRONG ONL NOT WRONG | Total-----------+--------------------------------------------+---------- MALE | 374 153 329 723 | 1,579 | 23.69 9.69 20.84 45.79 | 100.00 -----------+--------------------------------------------+---------- FEMALE | 689 275 389 776 | 2,129 | 32.36 12.92 18.27 36.45 | 100.00 -----------+--------------------------------------------+---------- Total | 1,063 428 718 1,499 | 3,708 | 28.67 11.54 19.36 40.43 | 100.00. graph pie, over(marital) by(sex) title("Pie Chart"). graph bar (count) id, over(marital) over(sex) title("Bar Chart")3MALE FEMALEPie Chart Pie ChartMARRIED WIDOWEDDIVORCED SEPARATEDNEVER MARRIEDGraphs by RESPONDENTS SEX 0 5,000 10,000 15,000count of idMALE FEMALEMARRIEDWIDOWEDDIVORCEDSEPARATEDNEVER MARRIEDMARRIEDWIDOWEDDIVORCEDSEPARATEDNEVER MARRIEDBar ChartCommands to use with a categorical variable and a continuous variable1. table varname, c(mean varname)2. graph barExamples. table newincome, c(mean educ)----------------------RECODE of |income |(TOTAL |FAMILY |INCOME) | mean(educ)----------+----------- <5k | 9.68085 <10k | 10.4861 <15k | 11.913 <20k | 12.8302 <25k | 12.6042 >25k | 14.0844 refused | 12.3235----------------------. graph bar (mean) educ, over(income) title("mean edu by income"). graph bar (mean) educ, over(newincome) title("mean edu by income (recoded)")0 5 10 15mean of educLT $1000$1000 TO 2999$3000 TO 3999$4000 TO 4999$5000 TO 5999$6000 TO 6999$7000 TO 7999$8000 TO 9999$10000 - 14999$15000 - 19999$20000 - 24999$25000 OR MOREREFUSEDmean edu by income 0 5 10 15mean of educ<5k <10k <15k <20k <25k >25k refusedmean edu by income (recoded)45Commands to use with two continuous variables1. scatter varname varname2. correlate varname varnameExamples. scatter lexp gnppc, title("Scatter Plot")55 60 65 70 75 80Life expectancy at birth0 10000 20000 30000 40000GNP per capitaScatter Plot. correlate lexp gnppc(obs=63) | lexp gnppc-------------+------------------ lexp | 1.0000 gnppc | 0.7182 1.0000(Datasets are downloadable at http://www.ssc.wisc.edu/~zzeng/soc357/gss.dta
View Full Document