---------------------------------------------------------------------------------------

name:  <unnamed>

log type:  text

opened on:  27 Sep 2012, 13:22:14

. cd "C:\Users\Michael\Documents\current class files\intro soc methods\new march 2005 incorrect year CPS for HW1"

C:\Users\Michael\Documents\current class files\intro soc methods\new march 2005 incorrect year CPS for HW1

*Let’s take a look at welfare income.

. summarize incwelfr

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |    103226    40.62242    478.8231          0      25000

* This suggests that the average welfare cost per US adult in the CPS is \$40 per year, see ipums.org for variable descriptions.

. summarize incwelfr if age <15

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |         0

* all the incwelfr values are missing for ages under 15. If you check ipums.org you will see that the universe for incwelfr is persons age 15+, meaning persons under 15 are not asked the question, i.e. are not in the universe for the question (so their values are missing).

. by sex: summarize incwelfr if age >20 & incwelfr>0

---------------------------------------------------------------------------------------

-> sex = Male

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |       142    3065.908    2711.885          1      13800

---------------------------------------------------------------------------------------

-> sex = Female

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |       972    3430.868    2885.764          1      25000

* Women are more likely to receive welfare, and the average welfare income for people on welfare is about \$3400 per year.

. by sex: summarize incwelfr if age >20 & incwelfr>0 [fweight= perwt_rounded]

------------------------------------------------------------------------------------

-> sex = Male

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |    256209    2972.657    2636.861          1      13800

------------------------------------------------------------------------------------

-> sex = Female

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

incwelfr |   1886278    3237.094    2906.139          1      25000

* It looks like there were 2.1 million people in the US on welfare in 2000 older than 20 years of age (there are some additional welfare recipients age 15-20).

. replace receives_welfare=1 if incwelfr>0 & incwelfr~=.

* This above command attaches a label to the variable itself.

. label define  receives_welfare_lbl 0 "no" 1 "yes"

* The above 2 commands first define labels that we want to attach to the values of receives_welfare, then we attach those labels to the values of the variable.

does |

respondent |

welfare |      Freq.     Percent        Cum.

------------+-----------------------------------

no |271,536,575       99.07       99.07

yes |  2,551,246        0.93      100.00

------------+-----------------------------------

Total |274,087,821      100.00

. table  educrec sex if age>20  [fweight= perwt_rounded], contents(freq mean  incwelfr mean  receives_welfare)

--------------------------------------------------

Educational attainment  |           Sex

recode                  |        Male       Female

------------------------+-------------------------

None or preschool |     409,822      463,962

|           0  201.8166229

|           0       .04848

|

Grades 1, 2, 3, or 4 |     988,458      959,869

|  21.2051377  186.4335592

|     .011155      .039831

|

Grades 5, 6, 7, or 8 |     4792742      5028804

| 10.72959028  119.6578288

|     .005356      .032857

|

| 20.88420617  134.0259969

|     .007086      .046607

|

| 22.49344775   214.192737

|     .008675        .0635

|

| 23.15243145  216.6690639

|     .007129      .073434

|

| 11.72673341  67.85343211

|     .003832      .021749

|

1 to 3 years of college |    2.35e+07     2.70e+07

| 7.269855825  44.67187372

|     .002034       .01304

|

4+ years of college |    2.40e+07     2.28e+07

| .3599692853   5.49143018

|     .000103      .002347

--------------------------------------------------

* Along with gender predicting welfare receipt, higher education, especially college education cuts welfare receipt drastically.

. table  educrec sex if age>20  [fweight= perwt_rounded], contents(freq mean  incwelfr mean  receives_welfare) row col

---------------------------------------------------------------

Educational attainment  |                  Sex

recode                  |        Male       Female        Total

------------------------+--------------------------------------

None or preschool |     409,822      463,962      873,784

|           0  201.8166229  107.1606301

|           0       .04848      .025742

|

Grades 1, 2, 3, or 4 |     988,458      959,869      1948327

|  21.2051377  186.4335592  102.6070993

|     .011155      .039831      .025283

|

Grades 5, 6, 7, or 8 |     4792742      5028804      9821546

| 10.72959028  119.6578288  66.50276097

|     .005356      .032857      .019437

|

Grade 9 |     1926372      2028431      3954803

| 20.88420617  134.0259969  78.91498944

|     .007086      .046607      .027357

|

Grade 10 |     2498378      2892776      5391154

| 22.49344775   214.192737  125.3551177

|     .008675        .0635      .038093

|

Grade 11 |     2607008      3013104      5620112

| 23.15243145  216.6690639  126.9022747

|     .007129      .073434      .042677

|

Grade 12 |    3.01e+07     3.47e+07     6.48e+07

| 11.72673341  67.85343211   41.8001018

|     .003832      .021749      .013432

|

1 to 3 years of college |    2.35e+07     2.70e+07     5.05e+07

| 7.269855825  44.67187372  27.25585651

|     .002034       .01304      .007915

|

4+ years of college |    2.40e+07     2.28e+07     4.68e+07

| .3599692853   5.49143018  2.858781299

|     .000103      .002347      .001196

|

Total |    9.09e+07     9.89e+07     1.90e+08

| 8.382322858  61.73025686  36.18842854

|      .00282       .01907       .01129

---------------------------------------------------------------

* the row and col options add nice summary and total data to the table. Of people older than 20 years of age in the US, 1.9% of women and 0.28% of men were on welfare.

. tabulate race

Race |      Freq.     Percent        Cum.

--------------------------------------+-----------------------------------

White |    113,475       84.87       84.87

Black/Negro |     13,626       10.19       95.06

American Indian/Aleut/Eskimo |      1,894        1.42       96.47

Asian or Pacific Islander |      4,715        3.53      100.00

--------------------------------------+-----------------------------------

Total |    133,710      100.00

. tabulate race, missing

Race |      Freq.     Percent        Cum.

--------------------------------------+-----------------------------------

White |    113,475       84.87       84.87

Black/Negro |     13,626       10.19       95.06

American Indian/Aleut/Eskimo |      1,894        1.42       96.47

Asian or Pacific Islander |      4,715        3.53      100.00

--------------------------------------+-----------------------------------

Total |    133,710      100.00

*Note: Every single one of the 133,710 cases has a race. By default, Stata leaves missing value cases out of the tables, but you can force Stata to show you the missing value cases if you invoke the “missing” option. How can there be no missing values? The census bureau must be imputing the missing values.

. summarize age

Variable |       Obs        Mean    Std. Dev.       Min        Max

-------------+--------------------------------------------------------

age |    133710    35.17964    22.21722          0         90

* And note, 90 is the highest recorded age. How can this be? Age is topcoded, to protect confidentiality of individuals with outlying values (see ipums variable documentation for confirmation of this).

. tabulate age

Age |      Freq.     Percent        Cum.

--------------------+-----------------------------------

Under 1 year |      1,713        1.28        1.28

1 |      1,932        1.44        2.73

2 |      1,950        1.46        4.18

3 |      1,939        1.45        5.63

4 |      1,965        1.47        7.10

5 |      1,998        1.49        8.60

6 |      2,059        1.54       10.14

7 |      2,176        1.63       11.77

8 |      2,163        1.62       13.38

9 |      2,243        1.68       15.06

10 |      2,202        1.65       16.71

11 |      2,083        1.56       18.27

12 |      2,035        1.52       19.79

13 |      2,047        1.53       21.32

14 |      1,979        1.48       22.80

15 |      2,046        1.53       24.33

16 |      1,965        1.47       25.80

17 |      1,998        1.49       27.29

18 |      1,847        1.38       28.67

19 |      1,826        1.37       30.04

20 |      1,722        1.29       31.33

21 |      1,687        1.26       32.59

22 |      1,638        1.23       33.81

23 |      1,622        1.21       35.03

24 |      1,662        1.24       36.27

25 |      1,666        1.25       37.52

26 |      1,640        1.23       38.74

27 |      1,726        1.29       40.03

28 |      1,801        1.35       41.38

29 |      1,995        1.49       42.87

30 |      1,907        1.43       44.30

31 |      1,991        1.49       45.79

32 |      1,890        1.41       47.20

33 |      1,898        1.42       48.62

34 |      2,024        1.51       50.13

35 |      2,134        1.60       51.73

36 |      2,123        1.59       53.32

37 |      2,099        1.57       54.89

38 |      2,064        1.54       56.43

39 |      2,228        1.67       58.10

40 |      2,190        1.64       59.74

41 |      2,115        1.58       61.32

42 |      2,137        1.60       62.92

43 |      2,091        1.56       64.48

44 |      2,114        1.58       66.06

45 |      2,118        1.58       67.64

46 |      1,939        1.45       69.10

47 |      1,957        1.46       70.56

48 |      1,827        1.37       71.93

49 |      1,767        1.32       73.25

50 |      1,865        1.39       74.64

51 |      1,802        1.35       75.99

52 |      1,825        1.36       77.35

53 |      1,695        1.27       78.62

54 |      1,301        0.97       79.59

55 |      1,323        0.99       80.58

56 |      1,324        0.99       81.57

57 |      1,304        0.98       82.55

58 |      1,128        0.84       83.39

59 |      1,129        0.84       84.24

60 |      1,154        0.86       85.10

61 |      1,051        0.79       85.89

62 |      1,073        0.80       86.69

63 |        938        0.70       87.39

64 |        952        0.71       88.10

65 |      1,014        0.76       88.86

66 |        869        0.65       89.51

67 |        926        0.69       90.20

68 |        908        0.68       90.88

69 |        904        0.68       91.56

70 |        913        0.68       92.24

71 |        885        0.66       92.90

72 |        770        0.58       93.48

73 |        797        0.60       94.08

74 |        814        0.61       94.68

75 |        796        0.60       95.28

76 |        704        0.53       95.81

77 |        646        0.48       96.29

78 |        687        0.51       96.80

79 |        602        0.45       97.25

80 |        514        0.38       97.64

81 |        476        0.36       97.99

82 |        425        0.32       98.31

83 |        427        0.32       98.63

84 |        325        0.24       98.87

85 |        306        0.23       99.10

86 |        248        0.19       99.29

87 |        209        0.16       99.44

88 |        172        0.13       99.57

89 |        155        0.12       99.69

90 (90+, 1988-2002) |        416        0.31      100.00

--------------------+-----------------------------------

Total |    133,710      100.00

. clear all

*Now on to the ingestion of the fresh ipums data:

* If you are downloading a stata file, there are no extra steps needed. If you are downloading an old fashioned ASCII file, first put the files all in one folder, and unzip the data file.

* Then cd (change directory) to the name of the directory you put the files in.

. cd "C:\Users\Michael\Documents\current class files\intro soc methods\new march 2005 incorrect year CPS for HW1"

C:\Users\Michael\Documents\current class files\intro soc methods\new march 2005 incorrect year CPS for HW1

* Then on the File menu, pick “do,” and the do-file in your folder should be listed. Pick it to run it.

. do "C:\Users\Michael\Documents\current class files\intro soc methods\new march 2005 incorrect year CPS for HW1\cps_00010.do"

. * NOTE: You need to set the Stata working directory to the path

. * where the data file is located.

.

. set more off

.

. clear

. quietly infix             ///

>   int     year     1-4    ///

>   long    serial   5-9    ///

>   float   hwtsupp  10-19  ///

>   byte    month    20-21  ///

>   float   wtsupp   22-29  ///

>   float   wtfinl   30-39  ///

>   byte    age      40-41  ///

>   byte    sex      42-42  ///

>   long    inctot   43-48  ///

>   using `"cps_00010.dat"'

.

. replace hwtsupp = hwtsupp / 10000

. replace wtsupp  = wtsupp  / 100

. replace wtfinl  = wtfinl  / 10000

.

. format hwtsupp %10.4f

. format wtsupp  %8.2f

. format wtfinl  %10.4f

.

. label var year    `"Survey year"'

. label var serial  `"Household serial number"'

. label var hwtsupp `"Household weight, Supplement"'

. label var month   `"Month"'

. label var wtsupp  `"Supplement Weight"'

. label var wtfinl  `"Final Basic Weight"'

. label var age     `"Age"'

. label var sex     `"Sex"'

. label var inctot  `"Total personal income"'

.

. label define hwtsupp_lbl 0000000000 `"0000000000"'

. label values hwtsupp hwtsupp_lbl

.

. label define month_lbl 01 `"January"'

. label define month_lbl 02 `"February"', add

. label define month_lbl 03 `"March"', add

. label define month_lbl 04 `"April"', add

. label define month_lbl 05 `"May"', add

. label define month_lbl 06 `"June"', add

. label define month_lbl 07 `"July"', add

. label define month_lbl 08 `"August"', add

. label define month_lbl 09 `"September"', add

. label define month_lbl 10 `"October"', add

. label define month_lbl 11 `"November"', add

. label define month_lbl 12 `"December"', add

. label values month month_lbl

.

. label define age_lbl 00 `"Under 1 year"'

. label define age_lbl 01 `"1"', add

. label define age_lbl 02 `"2"', add

. label define age_lbl 03 `"3"', add

. label define age_lbl 04 `"4"', add

. label define age_lbl 05 `"5"', add

. label define age_lbl 06 `"6"', add

. label define age_lbl 07 `"7"', add

. label define age_lbl 08 `"8"', add

. label define age_lbl 09 `"9"', add

. label define age_lbl 10 `"10"', add

. label define age_lbl 11 `"11"', add

. label define age_lbl 12 `"12"', add

. label define age_lbl 13 `"13"', add

. label define age_lbl 14 `"14"', add

. label define age_lbl 15 `"15"', add

. label define age_lbl 16 `"16"', add

. label define age_lbl 17 `"17"', add

. label define age_lbl 18 `"18"', add

. label define age_lbl 19 `"19"', add

. label define age_lbl 20 `"20"', add

. label define age_lbl 21 `"21"', add

. label define age_lbl 22 `"22"', add

. label define age_lbl 23 `"23"', add

. label define age_lbl 24 `"24"', add

. label define age_lbl 25 `"25"', add

. label define age_lbl 26 `"26"', add

. label define age_lbl 27 `"27"', add

. label define age_lbl 28 `"28"', add

. label define age_lbl 29 `"29"', add

. label define age_lbl 30 `"30"', add

. label define age_lbl 31 `"31"', add

. label define age_lbl 32 `"32"', add

. label define age_lbl 33 `"33"', add

. label define age_lbl 34 `"34"', add

. label define age_lbl 35 `"35"', add

. label define age_lbl 36 `"36"', add

. label define age_lbl 37 `"37"', add

. label define age_lbl 38 `"38"', add

. label define age_lbl 39 `"39"', add

. label define age_lbl 40 `"40"', add

. label define age_lbl 41 `"41"', add

. label define age_lbl 42 `"42"', add

. label define age_lbl 43 `"43"', add

. label define age_lbl 44 `"44"', add

. label define age_lbl 45 `"45"', add

. label define age_lbl 46 `"46"', add

. label define age_lbl 47 `"47"', add

. label define age_lbl 48 `"48"', add

. label define age_lbl 49 `"49"', add

. label define age_lbl 50 `"50"', add

. label define age_lbl 51 `"51"', add

. label define age_lbl 52 `"52"', add

. label define age_lbl 53 `"53"', add

. label define age_lbl 54 `"54"', add

. label define age_lbl 55 `"55"', add

. label define age_lbl 56 `"56"', add

. label define age_lbl 57 `"57"', add

. label define age_lbl 58 `"58"', add

. label define age_lbl 59 `"59"', add

. label define age_lbl 60 `"60"', add

. label define age_lbl 61 `"61"', add

. label define age_lbl 62 `"62"', add

. label define age_lbl 63 `"63"', add

. label define age_lbl 64 `"64"', add

. label define age_lbl 65 `"65"', add

. label define age_lbl 66 `"66"', add

. label define age_lbl 67 `"67"', add

. label define age_lbl 68 `"68"', add

. label define age_lbl 69 `"69"', add

. label define age_lbl 70 `"70"', add

. label define age_lbl 71 `"71"', add

. label define age_lbl 72 `"72"', add

. label define age_lbl 73 `"73"', add

. label define age_lbl 74 `"74"', add

. label define age_lbl 75 `"75"', add

. label define age_lbl 76 `"76"', add

. label define age_lbl 77 `"77"', add

. label define age_lbl 78 `"78"', add

. label define age_lbl 79 `"79"', add

. label define age_lbl 80 `"80"', add

. label define age_lbl 81 `"81"', add

. label define age_lbl 82 `"82"', add

. label define age_lbl 83 `"83"', add

. label define age_lbl 84 `"84"', add

. label define age_lbl 85 `"85"', add

. label define age_lbl 86 `"86"', add

. label define age_lbl 87 `"87"', add

. label define age_lbl 88 `"88"', add

. label define age_lbl 89 `"89"', add

. label define age_lbl 90 `"90 (90+, 1988-2002)"', add

. label define age_lbl 91 `"91"', add

. label define age_lbl 92 `"92"', add

. label define age_lbl 93 `"93"', add

. label define age_lbl 94 `"94"', add

. label define age_lbl 95 `"95"', add

. label define age_lbl 96 `"96"', add

. label define age_lbl 97 `"97"', add

. label define age_lbl 98 `"98"', add

. label define age_lbl 99 `"99+"', add

. label values age age_lbl

.

. label define sex_lbl 1 `"Male"'

. label define sex_lbl 2 `"Female"', add

. label values sex sex_lbl

.

. label define inctot_lbl 999999 `"999999"'

. label values inctot inctot_lbl

* Don’t forget to save your STATA file when you are done.

.

.

.

end of do-file

. clear all

. exit, clear