-------------------------------------------------------------------------------
       log:  C:\AAA Miker Files\newer web pages\soc_meth_proj3\class 4.smcl
  log type:  smcl
 opened on:  21 May 2003, 11:24:33

. set mem 50m

Current memory allocation

current memory usage settable value description (1M = 1024k) -------------------------------------------------------------------- set maxvar 5000 max. variables allowed 1.733M set memory 50M max. data space 50.000M set matsize 400 max. RHS vars in models 1.254M ----------- 52.987M

. graph using "C:\AAA Miker Files\newer web pages\soc_meth_proj3\Gender age ear > nings.gph"

. graph using "C:\AAA Miker Files\newer web pages\soc_meth_proj3\gender age ed. > gph"

. use "C:\AAA Miker Files\newer web pages\soc_meth_proj3\cps_y2k_numeric.dta", > clear

. table age sex

-------------------------- | p20 p15 | male female ----------+--------------- 0 | 902 811 1 | 1,012 920 2 | 989 961 3 | 1,020 919 4 | 952 1,013 5 | 1,002 996 6 | 1,035 1,024 7 | 1,096 1,080 8 | 1,106 1,057 9 | 1,124 1,119 10 | 1,118 1,084 11 | 1,022 1,061 12 | 1,028 1,007 13 | 1,054 993 14 | 978 1,001 15 | 1,038 1,008 16 | 1,025 940 17 | 1,012 986 18 | 923 924 19 | 942 884 20 | 847 875 21 | 847 840 22 | 807 831 23 | 798 824 24 | 784 878 25 | 798 868 26 | 797 843 27 | 855 871 28 | 899 902 29 | 919 1,076 30 | 964 943 31 | 998 993 32 | 922 968 33 | 923 975 34 | 952 1,072 35 | 1,066 1,068 36 | 1,024 1,099 37 | 1,023 1,076 38 | 1,019 1,045 39 | 1,074 1,154 40 | 1,031 1,159 41 | 1,001 1,114 42 | 1,028 1,109 43 | 1,060 1,031 44 | 1,026 1,088 45 | 1,044 1,074 46 | 918 1,021 47 | 961 996 48 | 892 935 49 | 839 928 50 | 924 941 51 | 885 917 52 | 883 942 53 | 815 880 54 | 634 667 55 | 662 661 56 | 616 708 57 | 651 653 58 | 504 624 59 | 517 612 60 | 547 607 61 | 508 543 62 | 532 541 63 | 456 482 64 | 436 516 65 | 464 550 66 | 416 453 67 | 435 491 68 | 398 510 69 | 424 480 70 | 395 518 71 | 392 493 72 | 323 447 73 | 337 460 74 | 366 448 75 | 350 446 76 | 275 429 77 | 272 374 78 | 276 411 79 | 252 350 80 | 212 302 81 | 198 278 82 | 173 252 83 | 159 268 84 | 118 207 85 | 110 196 86 | 79 169 87 | 77 132 88 | 52 120 89 | 53 102 90 | 121 295 --------------------------

. *That's just like using tabulate to cross tabulate age and sex . table age sex, contents (mean ernval2)

------------------------------ | p20 p15 | male female ----------+------------------- 0 | 0 0 1 | 0 0 2 | 0 0 3 | 0 0 4 | 0 0 5 | 0 0 6 | 0 0 7 | 0 0 8 | 0 0 9 | 0 0 10 | 0 0 11 | 0 0 12 | 0 0 13 | 0 0 14 | 0 0 15 | 358.9066 237.7391 16 | 1034.555 696.8564 17 | 1685.804 1470.296 18 | 3256.117 2903.62 19 | 6180.71 5154.389 20 | 8064.335 5878.957 21 | 9959.556 7101.669 22 | 12128.76 8590.962 23 | 14623.76 10270.05 24 | 16481.92 11636.9 25 | 20902.39 13811.94 26 | 24276.9 15750.91 27 | 25474.01 16302.89 28 | 27417.74 16703.85 29 | 27814.31 17828.96 30 | 29839.51 17174.32 31 | 31598.28 18059.29 32 | 34460.11 18063.74 33 | 34904.86 19340.78 34 | 34620.96 17544.7 35 | 36505.16 19231.13 36 | 37502.23 18436.33 37 | 37686.13 18566.77 38 | 40886.73 20323.18 39 | 40714.84 18531.64 40 | 38992.59 20154.87 41 | 39452.46 21551.37 42 | 41979.26 21292.34 43 | 40804.45 21790.84 44 | 40789.16 20274.15 45 | 39718.97 21736.62 46 | 42730.95 21239.43 47 | 42783.79 21636.39 48 | 45377.23 21605.61 49 | 43001.77 21963.61 50 | 43366.89 21823.49 51 | 42470.98 22146.05 52 | 42029.13 21475.88 53 | 44518.15 20417.05 54 | 40579.79 19080.14 55 | 40002.8 18192.76 56 | 39262.53 19099.1 57 | 40540.59 15432.12 58 | 34512.29 15309.23 59 | 34754.65 14814.33 60 | 31289.06 13148.44 61 | 29602.38 13898.95 62 | 24327.11 10629.85 63 | 21897.96 7777.759 64 | 19935.72 7266.785 65 | 15314.79 5157.113 66 | 12429.09 3629.925 67 | 9046.913 3427.409 68 | 10520.75 3109.065 69 | 7394.212 2579.933 70 | 7469.731 1319.745 71 | 5409.038 2365.813 72 | 6568.935 1410.045 73 | 7248.267 1370.62 74 | 5254.582 1228.623 75 | 3330.326 1016.991 76 | 2335.666 946.6294 77 | 4229.669 803.0267 78 | 1679.007 441.7032 79 | 4122.377 624.6543 80 | 3185.873 250.0298 81 | 3836.202 594.5756 82 | 2204.63 326.3413 83 | 3118.245 705.5597 84 | 1823.475 519.0966 85 | 1242.727 33.20408 86 | 1743.038 0 87 | 792.2208 198.4848 88 | 400 0 89 | 4883.34 0 90 | 942.1487 209.1525 ------------------------------

. table age sex [fweight=wgt2], contents (mean ernval2) replace

------------------------------ | p20 p15 | male female ----------+------------------- 0 | 0 0 1 | 0 0 2 | 0 0 3 | 0 0 4 | 0 0 5 | 0 0 6 | 0 0 7 | 0 0 8 | 0 0 9 | 0 0 10 | 0 0 11 | 0 0 12 | 0 0 13 | 0 0 14 | 0 0 15 | 396.319 183.7211 16 | 1020.365 713.4266 17 | 1610.828 1465.907 18 | 3243.765 2903.755 19 | 6337.779 5588.09 20 | 7875.336 5902.063 21 | 9815.773 7328.729 22 | 12394.81 8554.747 23 | 14481.45 10592.13 24 | 16769.89 12120.36 25 | 21444.51 14749.22 26 | 25498.8 16947.93 27 | 26538.1 17267.25 28 | 29215 17458.98 29 | 29169.08 18324.94 30 | 31499.9 18273.63 31 | 31936.6 19024.94 32 | 36682.82 19109.75 33 | 36278.11 20206.75 34 | 36316.5 18442.74 35 | 38402.54 19924.91 36 | 38287.57 19088.01 37 | 38749.87 19072.99 38 | 42316.86 20287.62 39 | 42051.19 18374.46 40 | 40630.51 20844.5 41 | 40755.96 22472.4 42 | 43016.46 21300.15 43 | 42146.82 22280.97 44 | 41745.25 20729.45 45 | 41480.81 22355.97 46 | 44197.24 21996.38 47 | 43890.82 22360.41 48 | 48550.66 22202.53 49 | 45050.73 22651.13 50 | 44697.07 22753.46 51 | 44547 22754.16 52 | 44251.02 22612.03 53 | 45776.5 21017.59 54 | 43153.59 19101.49 55 | 41474.79 18239.59 56 | 39952.82 19010.76 57 | 41662.03 15656.72 58 | 35080.16 15512.6 59 | 36322.61 14706 60 | 31705.73 13512.34 61 | 32187.32 14354.84 62 | 25179.5 10299.66 63 | 23907.55 8270.257 64 | 19459.92 7731.409 65 | 16299.65 5060.667 66 | 12058.98 3553.587 67 | 9790.435 3496.792 68 | 11131.51 3238.803 69 | 7651.15 2648.869 70 | 7762.551 1359.102 71 | 6021.53 2262.92 72 | 7369.7 1384.317 73 | 7036.694 1555.345 74 | 5632.944 1439.468 75 | 3564.04 1088.662 76 | 2251.615 956.7117 77 | 4255.651 904.6344 78 | 1519.77 535.3051 79 | 3802.322 544.5576 80 | 4496.77 249.0527 81 | 4428.576 788.4609 82 | 1690.87 356.2551 83 | 3756.357 882.6436 84 | 2287.44 491.2287 85 | 1471.763 48.12194 86 | 1797.336 0 87 | 753.168 339.1927 88 | 375.0294 0 89 | 2934.092 0 90 | 1295.411 188.9299 ------------------------------

. *This is a new dataset, and a small one, so this would be easy to save anywhe > re. . describe

Contains data obs: 182 vars: 3 size: 1,820 (100.0% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- age byte %8.0g p15 sex byte %8.0g sexnm p20 table1 float %9.0g mean(ernval2) ------------------------------------------------------------------------------- Sorted by: age sex Note: dataset has changed since last saved

. rename table1 mean_earnings

. graph mean_earnings age if sex==2

. graph mean_earnings age if sex==1

. gen men_earnings= mean_earnings if sex==1 (91 missing values generated)

. gen female_earnings= mean_earnings if sex==2 (91 missing values generated)

. graph men_earnings female_earnings age

. *Now let's say we wanted to make the axes look nicer . graph men_earnings female_earnings age, xlab(0 (5) 90) ylab(0 (10000) 50000)

. *That last command got the axes looking right. . graph men_earnings female_earnings age, xlab(0 (5) 90) ylab(0 (10000) 50000) > b2title("age")

. *there's a tutorial for graph . tutorial graph file graph.tut not found r(601);

. tutorial graphics

___ ____ ____ ____ ____ tm /__ / ____/ / ____/ ___/ / /___/ / /___/ How to Make Graphs --------------------------------------------------

We are about to demonstrate Stata's graphics. Actually, we will only scratch the surface of those capabilities, so you should read the manual.

This tutorial can be discontinued at any time by pressing the Break button; under Unix(console), type q.

This will cause Stata to terminate the tutorial and Stata will await your next command.

If you are a Unix(console) user, you will not be able to view the graphs.

Graphic styles --------------

Stata provides eight graphic styles, known as

twoway meaning two-way scatterplots matrix meaning two-way scatterplot matrices histogram meaning histograms oneway meaning one-way scatterplots box meaning box-and-whisker plots star meaning star charts bar meaning bar charts pie meaning pie charts

Please type y or n in the Command window: Would you like to see examples of each? (y/n) . y (Press the Space Bar when you see --more-- in this window) Would you like to see them again? (y/n) . n

Enough preliminary ------------------

------------------------------------------------------------------------------- To teach you how to use Stata's graphics capabilities, we will use the auto- mobile data that we used in the introduction. Remember that these data are stored in the file 'auto.dta': -------------------------------------------------------------------------------

. use "C:\Stata/auto", clear (1978 Automobile Data)

------------------------------------------------------------------------------- We will begin with the two-way scatterplot, plotting miles per gallon against engine displacement: -------------------------------------------------------------------------------

. graph mpg displacement

------------------------------------------------------------------------------- Stata will allow us to manipulate the basic image and add labeling, grid lines, and titles. Let's ask Stata to label the axes: -------------------------------------------------------------------------------

. graph mpg displacement, xlabel ylabel

------------------------------------------------------------------------------- We'll get to grid lines and titles in a moment, but first we'll show you how to vary the text size. The Stata parameter textsize says how big the characters are supposed to be. Its default value is 100, which means 100% of what Stata thinks looks good. Let's redraw our last image varying the textsize: -------------------------------------------------------------------------------

. set textsize 200

. graph mpg displacement, xlabel ylabel

. set textsize 125

. graph mpg displacement, xlabel ylabel

. set textsize 75

. graph mpg displacement, xlabel ylabel

------------------------------------------------------------------------------- You get the idea. We're not going to play with textsize again, but you may want to. We'll set it back to the default 100: -------------------------------------------------------------------------------

. set textsize 100

------------------------------------------------------------------------------- Now let's return to adding titles and grid lines. There are two titles on every side of the graph, called t1title, t2title, b1title, b2title, l1title, l2title, r1title, and r2title. The 't', 'b', 'l', and 'r' stand for top, bottom, left, and right. The b1title is also known as simply the title.

Here's a graph showing where all the titles are: -------------------------------------------------------------------------------

. graph mpg displacement, t1title(This is the t1title) t2title(This is the t2title) b1title(This is the b1title also known as title) b2title(This is the b2title) r1title(This is the r1title) r2title(This is the r2title) l1title(This is the l1title) l2title(This is the l2title) --Break-- --Break-- r(1);

. exit, clear