-------------
       log:  /disk/u4/SCCS/morg/sources/educ2001.smcl
  log type:  smcl
 opened on:  24 Jul 2002, 13:27:34

. set memory 500m
(512000k)

. set more 1

. ! /bin/rm -f /tmp/aef.raw aef.dct dcthead


. * run with stata6 -p0 do annual2001 to get Stata 5 format
. ! echo >dcthead   dictionary using /tmp/aef.raw


. program define aef2
  1. * '-A' are missing value indicators   in the earlier files.
. if `1' <  1994 {!zcat /home/data/morg/raw/morg`2'.Z |tr "\-A" "  " >/tmp/aef.raw}
  2. if `1' >= 1994 {!zcat /home/data/morg/raw/morg`2'.Z >/tmp/aef.raw}
  3. ! cat /home/data/morg/sources/dcthead /home/data/morg/sources/aef`3'.dbd >./aef.dct
  4. quietly infile using aef if age>15&age!=.
  5. #delimit cr
delimiter now cr
.
. * Geography
. generate int year = `1'
  6. if `1'== 1995 { replace hhid = hhid94 if intmonth<9
  7.               drop hhid94  }
  8. if `1' >  1995 { replace smsa93   = . if smsa93<2 }
  9. replace smsasize = . if smsasize <=0
 10. if `1' == 1995 { replace smsastat = smsa995 if intmonth>8
 11.                replace icntcity = icntct94 if intmonth<9
 12.                replace centcity = centcitx if intmonth<9
 13.                replace smsa93   = . if intmonth>=9 & smsa93<2
 14.                replace smsa93   = . if intmonth<9
 15.                drop pmsarank
 16.                generate smsa80 = smsasize if intmonth < 10  }
 17. if `1' > 1995 & `1' < 1998 {  replace smsastat = smsa995 }
 18. replace smsastat = . if smsastat==3 | smsastat<0
 19. if `1' == 1994  { replace hhid = hhid94
 20.                 drop hhid94
 21.                 drop smsa93
 22.                 replace centcity = centcitx
 23.                 replace icntcity = icntct94
 24.                 replace eligible = . if eligible == 0
 25.                 replace pmsarank = . if intmonth > 3
 26.                 replace pmsarank = . if pmsarank <= 0
 27.                 replace cmsarank = . if intmonth > 3 }
 28. if `1' > 1995 & `1' <= 1997 { drop hhid94 pmsarank }
 29. if `1' > 1993 & `1' < 1998 { drop centcitx icntct94 smsa995  }
 30. if `1' > 1993  { replace hurespli =. if hurespli <0
 31.                replace peinusyr = . if peinusyr < 0 }
 32. replace centcity = . if centcity==4 | centcity<=0
 33. if `1' >= 1986 & `1' < 1994 { replace pmsarank = . if pmsarank<=0 }
 34. if `1' >= 1995 & `1' <= 1997 { drop cmsarank}
 35. if `1' >= 1986 { replace icntcity = . if icntcity<=0}
 36. if `1' >  1984 & `1' < 1995 { replace cmsarank = . if cmsarank<=0}
 37. if `1' >= 1989 { replace msafips  = . if msafips <=0
 38.                replace cmsacode = . if cmsacode<=0}
 39. if `1' == 1983 { drop docc70 occ70 }
 40. if `1' == 1985 { replace smsarank = . if intmonth > 9}
 41. if `1' == 1984 { drop icntcity pmsarank cmsarank }
 42. if `1' == 1985 & intmonth < 10 { drop icntcity pmsarank cmsarank }
 43. if `1' == 1994 { replace cmsarank = . if intmonth>3 }
 44. *replace smsasize=. if smsasize<=0
. if `1' <  1985 { generate byte smsa70 = smsasize }
 45. if `1' >  1985 & `1' < 1995 { generate byte smsa80 = smsasize }
 46. if `1' == 1985 { generate byte smsa70 = smsasize if intmonth<10 }
 47. if `1' == 1985 { generate byte smsa80 = smsasize if intmonth>9 }
 48. drop smsasize
 49. if `1' > 1985 & `1' <  1989 { drop smsarank }
 50. if `1' < 1983             { drop unioncov unionmme occ80 ind80 }
 51.
. * Demography
. if `1' > 1983 & `1' < 1994 { replace ownchild = . if ownchild ==0
 52.                          replace ownchild = ownchild - 1
 53.                          generate int ch613=chldpres
 54.                          generate int ch1417=chldpres }
 55. if `1' > 1983 & `1' < 1989 { generate int ch05= chldpres
 56.                          recode ch05   4 6/8 = 1   0/3 5   = 0
 57.                          recode ch613  3 5 7/8 = 1 0/2 4 6 = 0
 58.                          recode ch1417 2 5/6 8 =1  0/1 3/4 7 = 0 }
 59. if `1' > 1988 & `1' < 1994 { generate int ch02 = chldpres
 60.                          generate int ch35 = chldpres
 61.                          recode ch02   2 6/8 12/14 16 = 1       0/1 3/5 9/11 15 = 0
 62.                          recode ch35   3 6 9/10 12/13 15/16 = 1 0/2 4/5 7/8 11 14 = 0
 63.                          recode ch613  4 7 9 11/12 14/16 = 1    0/3 5/6 8 10 13 = 0
 64.                          recode ch1417 5 8 10/11 13/16 = 1      0/4 6/7 9 12 = 0
 65.                          generate int ch05 = ch02
 66.                          replace ch05 = ch35 if ch35 == 1
 67.                          label variable ch02 "Children 0-2"
 68.                          label variable ch35 "Children 3-5"}
 69. if `1' > 1983 & `1' < 1994 { label variable ch05 "Children 0-5"
 70.                label variable ch613 "Children 6-13"
 71.                label variable ch1417 "Children 6-17" }
 72. if `1' == 1998 { drop ownchild chldpres }
 73. if `1' >= 1999 {replace ownchild = . if ownchild < 0
 74.                 replace chldpres = . if chldpres < 0
 75.                 generate int ch02 = chldpres
 76.                 generate int ch35 = chldpres
 77.                 generate int ch613 = chldpres
 78.                 generate int ch1417 = chldpres
 79.                 recode ch02   1 5/7 11/13 15 = 1      0 2/4 8/10 14 = 0
 80.                 recode ch35   2 5 8/9 11/12 14/15 = 1 0/1 3/4 6/7 10 13 =0
 81.                 recode ch613  3 6 8 10/11 13/15 = 1   0/2 4/5 7 9 12 = 0
 82.                 recode ch1417 4 7 9/10 12/15 = 1      0/3 5/6 8 11 = 0
 83.                 generate int ch05 = ch02
 84.                 replace ch05 = ch35 if ch35 == 1  }
 85.
. if `1' == 1999 { replace ownchild = . if intmonth < 10
 86.                  replace chldpres = . if intmonth < 10
 87.                  replace ch613    = . if intmonth < 10
 88.                  replace ch1417   = . if intmonth < 10
 89.                  replace ch05     = . if intmonth < 10
 90.                  replace ch02     = . if intmonth < 10
 91.                  replace ch35     = . if intmonth < 10   }
 92. if `1' > 1988 & `1' < 1992 { drop grade92   }
 93. if `1' <  1989 { replace gradeat = gradeat - 1
 94.                replace marital = 7 if marital==5 }
 95. if `1' >  1991 { replace grade92 = . if grade92 < 0 }
 96. if `1' >= 1998 { replace ged      = . if ged < 0
 97.                  replace gedhigr  = . if gedhigr < 0
 98.                  replace yrcoll   = . if yrcoll < 0
 99.                  replace grprof   = . if grprof < 0
100.                  replace gr6cor   = . if gr6cor < 0
101.                  replace ms123    = . if ms123 < 0      }
102. if `1' == 1992 | `1' == 1993 { drop gradecp gradeat}
103. if `1' == 1995 { replace relref94 = . if intmonth > 2
104.                replace relref95 = . if intmonth < 3 }
105. if `1' > 1995  { drop relref94 }
106. if `1' == 1994 { drop relref95 }
107. if `1' >= 1994 { replace veteran  = . if veteran  < 0
108.                replace penatvty = . if penatvty < 0
109.                replace pemntvty = . if pemntvty < 0
110.                replace pefntvty = . if pefntvty < 0
111.                replace prcitshp = . if prcitshp < 0
112.                replace prcitflg = . if prcitflg < 0 }
113. if `1' > 1989  { replace ethnic = . if ethnic < 0
114.                  replace ethnic = . if ethnic >= 10}
115.
. * Employment
. if `1' >= 1994 { replace occ80    = . if occ80  <0
116.                replace ind80    = . if ind80  < 10
117.                replace class94  = . if class94<0 }
118. #delimit ;
delimiter now ;
. if `1' >= 1983  { generate int docc80=occ80;
119. recode docc80  1/6=1 7/22=2 23/37=3 44/59=4 64/68=5 69/83=6 84/89=7
> 95/106=8 113/154=9 155/159=10 178/179=11 43 63 163/177 183/199=12
>  203/208=13 213/225=14 226/235=15 243=16 253/257=17 258/259=18
>  263/278=19 283/285=20 303/307=21 308/309=22 313/315=23 337/344=24
>  354/357=25 316/336 345/353 359/389=26 403/407=27 413/427=28
>  433/444=29 445/447=30 448/455=31 456/469=32 503/549=33 553/599=34
>  613/699=35 703/779=36 783/799=37 803/814=38 823/859=39 869=40
> 875/883=41 863/868 873 874 885/889=42 473/476=43 477/489=44 494/499=45
> 905=46};
120. if `1'<= 1982{
> replace dind=ind70 ;
121. recode dind 18/19=1 17=2 47/57=3 67/77=4 107/109=5 118=6 119/138=7
>  139/149=8 157/168 258=9 169=10 177/198=11 199/209=12 219 =13
>  227=14 228/238=15 239/257=16 259=18 268/298=19 299=20
>  307/318=21 319/327=22 328/337=23 338/339=24 347/369=25
>  377/378=26 379/
>  387=27 388/398=28 407/429=29 447/449=30 467/479=31
>  507/588=32 607/698=33 707/709=34 717/718=35
>  769=36 727/748=37 749/759=38 777/798=39 807/809=40  838=41
>  828/837 839/848=42 877/879=44 857/868=43 849 869 887/897=
>  45 027 028 = 46 907/937=52 } ;
122. if `1' <=1993 & `1' >=1983 {replace dind=ind80;
123. recode
>  dind 12/30=1 10/11=2 40/50=3 60=4 230/241=5 242=6 250/262=7
>  270/280=8 281/300=9 301=10 310/332=11 340/350=12
>  351=13 352=14 360/370=15 371/382=16 390=17 391/392=18
>  100/122=19 130=20 132/150=21 151/152=22 160/162=23 171/172=24
>  180/192=25 200/201=26 210/212=27 220/222=28
>  400/432=29 440/442=30 450/472=31 500/571=32 580/691=33 700/710=34
>  711/712=35 761=36 721/750=37 751/760=38 762/791=39 800/810=40
>  831=41 812/830 832/840=42 842/860=43 861/871=44 841 872/893=45
>  31/32=46 900/932=52 991=51};
124. if `1' >= 1994 {replace dind=ind80;
125. recode
> dind 12/30=1 10/11=2 40/50=3 60=4 230/241=5 242=6 250/262=7
>  270/280=8 281/300=9 301=10 310/332=11 340/350=12
>  351=13 352=14 360/370=15 371/382=16 390=17 391/392=18
>  100/122=19 130=20 132/150=21 151/152=22 160/162=23 171/172=24
>  180/192=25 200/201=26 210/212=27 220/222=28
>  400/432=29 440/442=30 450/472=31 500/571=32 580/691=33
>  700/710=34 711/712=35 761=36 721/750=37 751/760=38 762/791=39
>  800/810=40 831=41 812/830 832/840=42 842/860=43
>  861/871=44 841 872/893 =45
>  032 031 =46 910 922 932 900 901
>  921 930 931 =52 991=51 };
126.  #delimit cr
delimiter now cr
. * Wages (If earnings are 0, then wage rate is missing, not zero).
. replace paidhr   = . if paidhr  <=0
127. replace paidhre  = . if paidhre <=0
128. replace earnhr   = . if earnhr  <=0
129. replace earnhre  = . if earnhre <=0
130. replace earnwke  = . if earnwke < 0
131. if `1' < 1989 {replace eligible = 2 if eligible == . }
132. if `1' >= 1989 {replace eligible = 2 if eligible == 0
133.               replace eligible = . if eligible < 0 }
134. if `1'  < 1989 {replace I25a = 0 if I25a ==.
135.                 replace I25b = 0 if I25b ==.
136.                 replace I25c = 0 if I25c ==.
137.                 replace I25d = 0 if I25d ==.}
138. if `1' >= 1994 {replace eligible = 0 if eligible ==.
139.                 replace I25a     = 0 if I25a <= 3
140.                 replace I25b     = 0 if I25b <= 3
141.                 *replace I25a = . if I25a < 0
.                 *replace I25b = . if I25b < 0
.                 replace earnhre  = . if earnhre ==1
142.                 replace uhourse  = . if lfsr94 >2 | lfsr94 <1
143.                 replace lfsr94    = . if lfsr94 < 0 }
144. if `1' >= 1996 { replace I25c = . if I25c < 0
145.                  replace I25d = . if I25d < 0  }
146. if `1' == 1995 { replace I25c = . if I25c < 0
147.                  replace I25d = . if I25d < 0
148.                  replace I25c = . if intmonth < 9
149.                  replace I25d = . if intmonth < 9  }
150. if `1' == 1994 { drop I25c I25d }
151. * Hours, Unions
. if `1' >= 1994 {
152.                replace reason94 = . if reason94< 0
153.                replace absent94 = . if absent94< 0
154.                replace studftpt = . if studftpt< 0
155.                replace ftpt94   = . if ftpt94  < 0
156.                replace hourslw  = . if hourslw < 0
157.                replace hourslw  = 99 if hourslw >99 & hourslw != .
158.                replace uhourse  = . if uhourse < 0
159.                replace why3594  = . if why3594 < 0
160.                replace unionmme = . if unionmme< 0
161.                replace unioncov = . if unioncov< 0 }
162.
. * Save and exit
.  ! /bin/rm -f /home/data/morg/annual/morg`2'.dta
163. compress
164. save /home/data/morg/annual/morg`2',old
165. ! /bin/chmod a+r /home/data/morg/annual/morg*.dta
166. ! /bin/chmod g+w /home/data/morg/annual/morg*.dta
167. ! /bin/chgrp web /home/data/morg/annual/morg*.dta
168. summarize
169. clear
170. ! /bin/rm -f aef.dct /tmp/aef.raw
171. end

.
. * Each block of commands does one year of the data. The data must be
. * decompressed, and possibly have dashes converted to blanks.
. * Then a dictionary for the particular year is prepared by
. * concatenating a one line header (with the file name) to a generic
. * dictionary body that covers several years of data that used the
. * same format.
. *Lastly, the data is read, modified, summarized and saved.
.
. *aef2 1979 79 79_83
. *aef2 1980 80 79_83
. *aef2 1981 81 79_83
. *aef2 1982 82 79_83
. *aef2 1983 83 79_83
. *aef2 1984 84 84_88
. *aef2 1985 85 84_88
. *aef2 1986 86 84_88
. *aef2 1987 87 84_88
. *aef2 1988 88 84_88
. *aef2 1989 89 89_93
. *aef2 1990 90 89_93
. *aef2 1991 91 89_93
. *aef2 1992 92 89_93
. *aef2 1993 93 89_93
. *aef2 1994 94 94_97
. *aef2 1995 95 94_97
. *aef2 1996 96 94_97
. *aef2 1997 97 94_97
. aef2 1998 98 98


(77399 real changes made, 77399 to missing)
(0 real changes made)
(811 real changes made, 811 to missing)
(0 real changes made)
(0 real changes made)
(42773 real changes made, 42773 to missing)
(261970 real changes made, 261970 to missing)
(77799 real changes made, 77799 to missing)
(182324 real changes made, 182324 to missing)
(0 real changes made)
(189778 real changes made, 189778 to missing)
(271442 real changes made, 271442 to missing)
(208739 real changes made, 208739 to missing)
(238533 real changes made, 238533 to missing)
(267588 real changes made, 267588 to missing)
(266661 real changes made, 266661 to missing)
(1171 real changes made, 1171 to missing)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(0 real changes made)
(1781 real changes made, 1781 to missing)
(85012 real changes made, 85012 to missing)
(85012 real changes made, 85012 to missing)
(85012 real changes made, 85012 to missing)
(85012 missing values generated)
(195380 changes made)
dind was byte now int
(280392 real changes made, 85012 to missing)
(195380 changes made)
(123402 real changes made, 123402 to missing)
(0 real changes made)
(184445 real changes made, 184445 to missing)
(0 real changes made)
(0 real changes made)
(123402 real changes made)
(0 real changes made)
(0 real changes made)
(102055 real changes made)
(123402 real changes made)
(0 real changes made)
(102055 real changes made, 102055 to missing)
(1171 real changes made, 1171 to missing)
(184372 real changes made, 184372 to missing)
(123402 real changes made, 123402 to missing)
(263541 real changes made, 263541 to missing)
(272611 real changes made, 272611 to missing)
(259816 real changes made, 259816 to missing)
(1171 real changes made, 1171 to missing)
(109836 real changes made, 109836 to missing)
(99 real changes made)
(15306 real changes made, 15306 to missing)
(233467 real changes made, 233467 to missing)
(123402 real changes made, 123402 to missing)
(145124 real changes made, 145124 to missing)

hourslw was int now byte
dind was int now byte
docc80 was int now byte
file /home/data/morg/annual/morg98.dta saved


    Variable |     Obs        Mean   Std. Dev.       Min        Max
-------------+-----------------------------------------------------
    intmonth |  280392    6.510692   3.456178          1         12
    hurespli |  280392    1.540565   .8676575          0         13
     grade92 |  280392    39.61597   2.839531         31         46
         ged |   90614    1.098771   .2983554          1          2
     gedhigr |    8950    6.257207   1.417525          1          8
      yrcoll |   71653    2.649338   1.007919          1          5
      grprof |   41859    1.694116   .4607864          1          2
      gr6cor |   12804    1.397923   .4894884          1          2
       ms123 |   13731    2.150462    .612277          1          3
     minsamp |  280392    5.988488    1.99997          4          8
       hhnum |  280392     1.05793   .2508091          1          6
       state |  280392    53.53248   26.12936         11         95
      smsa93 |  202993    5.195031   1.681316          2          7
    centcity |  237619    2.003152   .7421608          1          3
     msafips |  202593    4513.267   2517.221         80       9360
    cmsacode |   98068    53.46612   26.81658          7         97
    smsastat |  279581    1.235409   .4242552          1          2
    icntcity |   18422    1.188905   .5396505          1          4
        hhid |       0
         sex |  280392    1.526491   .4992986          1          2
     veteran |  279221    5.605452   1.187244          1          6
     why3594 |   46925    14.27207   7.069656          1         23
     class94 |  195380    4.132363   1.180634          1          8
    unioncov |  135268    1.982309   .1318255          1          2
    studftpt |   20576    1.090202   .2864782          1          2
    relref95 |  280392    2.952702   2.967109          1         18
         age |  280392    44.42307    18.0935         16         90
     pfamrel |  280392    1.396834   1.031189          0          4
     marital |  280392    3.205576   2.605291          1          7
        race |  280392    1.237357   .6583332          1          4
     hourslw |  170556    39.04228   14.05205          1         99
    reason94 |   16851    5.407098   2.562863          1         13
    absent94 |    7781    5.949492   3.261191          4         14
       ind80 |  195380    584.2959    274.766         10        991
       occ80 |  195380    361.1335   248.4527          4        905
     uhourse |  163031    39.22312   11.65956          0         99
     paidhre |  156990    1.388369   .4873807          1          2
    unionmme |  156990    1.861634   .3452843          1          2
      ethnic |  278611    7.631877   1.345716          1          9
      lfsr94 |  279221    2.725852   2.328977          1          7
      ftpt94 |  279221    2.709664    2.42678          1         12
        dind |  195380    31.26444   13.41739          1         52
    eligible |  280392    1.440105   .4964005          1          2
     earnhre |   95947    1083.531     631.37         25       9999
     earnwke |  156990    560.8707   436.1196          0       2884
      weight |  280392    2195.712   1067.924          0   15050.86
      earnwt |  280392    8782.849   4299.018          0   59131.54
        I25a |  280392    .2254023   2.798935          0         43
        I25b |  280392    2.720409   10.32749          0         42
        I25c |   96020    .2584462   .4377828          0          1
        I25d |  156990    .2364291     .42489          0          1
    penatvty |  280392    80.83045   73.14627         57        555
    pemntvty |  280392    88.80481   80.71373         57        555
    pefntvty |  280392    88.93425   80.41014         57        555
    prcitshp |  280392    1.401695   1.126103          1          5
    prcitflg |  280392    .1307527   1.883312          0         41
    peinusyr |  280392      .95971   2.995619          0         15
    hrlonglk |  280392    1.991662   .1288689          0          2
      lineno |  280392    1.734201   1.003492          1         16
        year |  280392        1998          0       1998       1998
      docc80 |  195380    22.25457   12.74363          1         46


. *aef2 1999 99 98
. *aef2 2000 00 98
. *aef2 2001 01 98
.
.
end of do-file

. exit,clear