. set memory 60m (61440k) . set more 1 . ! /bin/rm -f /tmp/aef.raw aef.dct dcthead . * Obtain raw data from Chung Underwood at BLS 202-606-7786 . ! echo >dcthead dictionary using /tmp/aef.raw . program define aef2 1. * '-A' are missing value indicators in the earlier files. . if `1' < 94 {!zcat /home/data/morg/raw/morg`1'.Z |tr "\-A" " " >/tmp/aef.ra > w} 2. if `1' >= 94 {!zcat /home/data/morg/raw/morg`1'.Z >/tmp/aef.raw} 3. ! cat /home/data/morg/sources/dcthead /home/data/morg/sources/aef`2'.dbd > > ./aef.dct 4. quietly infile using aef if age>15&age!=. 5. #delimit cr delimiter now cr . . * Geography . generate byte year = `1' 6. if `1'== 95 { replace hhid = hhid94 if intmonth<9 7. drop hhid94 } 8. if `1' > 95 { replace smsa93 = . if smsa93<2 } 9. if `1' >= 94 { replace smsa93 = . } 10. replace smsasize = . if smsasize <=0 11. if `1' == 95 { replace smsastat = smsa995 if intmonth>8 12. replace icntcity = icntct94 if intmonth<9 13. replace centcity = centcitx if intmonth<9 14. generate byte smsa80 = smsasize if intmonth<=8 15. replace smsa93 = . if intmonth>9 & smsa93<2 16. replace smsa93 = . if intmonth<10 } 17. if `1' > 95 & `1' < 98 { replace centcity = centcitx 18. replace smsastat = smsa995 } 19. replace smsastat = . if smsastat==3 | smsastat<0 20. if `1' == 94 { replace hhid = hhid94 21. drop hhid94 22. replace icntcity = icntct94 23. replace eligible = . if eligible == 0} 24. if `1' >= 95 & `1' <= 97 { drop hhid94 } 25. if `1' > 93 & `1' < 98 { drop centcitx icntct94 smsa995 } 26. replace centcity = . if centcity==4 | centcity<=0 27. if `1' >= 86 { replace pmsarank = . if pmsarank<=0 28. replace icntcity = . if icntcity<=0} 29. if `1' > 84 { replace cmsarank = . if cmsarank<=0} 30. if `1' >= 89 { replace msafips = . if msafips <=0 31. replace cmsacode = . if cmsacode<=0} 32. if `1' == 83 { drop docc70 } 33. if `1' == 85 { replace smsarank = . if intmonth > 9} 34. if `1' == 84 | `1'==85 { drop icntcity pmsarank cmsarank } 35. if `1' == 94 { replace cmsarank = . if intmon>3 } 36. if `1' > 94 { drop cmsarank pmsarank } 37. replace smsasize=. if smsasize<=0 38. if `1' < 85 { generate byte smsa70 = smsasize } 39. if `1' > 85 & `1' < 95 { generate byte smsa80 = smsasize } 40. if `1' == 85 { generate byte smsa70 = smsasize if intmonth<10 } 41. if `1' == 85 { generate byte smsa80 = smsasize if intmonth>9 } 42. drop smsasize 43. if `1' > 85 & `1' < 89 { drop smsarank } 44. if `1' < 83 { drop unioncov unionmme occ80 ind80 } 45. . * Demography . if `1' > 83 & `1' < 94 { replace ownchild = . if ownchild ==0 46. replace ownchild = ownchild - 1 47. generate int ch613=chldpres 48. generate int ch1417=chldpres } 49. if `1' > 83 & `1' < 89 { generate int ch05= chldpres 50. recode ch05 4 6/8 = 1 0/3 5 = 0 51. recode ch613 3 5 7/8 = 1 0/2 4 6 = 0 52. recode ch1417 2 5/6 8 =1 0/1 3/4 7 = 0} 53. if `1' > 88 & `1' < 94 { generate int ch02 = chldpres 54. generate int ch35 = chldpres 55. recode ch02 2 6/8 12/14 16 = 1 0/1 3/5 9/11 15 = > 0 56. recode ch35 3 6 9/10 12/13 15/16 = 1 0/2 4/5 7/8 > 11 14 = 0 57. recode ch613 4 7 9 11/12 14/16 = 1 0/3 5/6 8 10 1 > 3 = 0 58. recode ch1417 5 8 10/11 13/16 = 1 0/4 6/7 9 12 = > 0 59. generate int ch05 = ch02 60. replace ch05 = ch35 if ch35 == 1 } 61. . if `1' > 88 & `1' < 92 { replace gradeat = gradeat2 62. drop grade92 } 63. drop gradeat2 64. if `1' < 89 { replace gradeat = gradeat - 1 65. drop gradecp2 66. replace marital = 7 if marital==5 } 67. if `1' > 88 & `1' < 92 { replace gradecp = gradecp2 68. drop gradecp2 } 69. if `1' > 91 { 70. replace grade92 = . if grade92 < 0 } 71. if `1' > 91 { drop gradecp gradecp2 gradeat} 72. if `1' == 95 { replace relref94 = . if intmonth > 2 73. replace relref95 = . if intmonth < 3 } 74. if `1' > 95 { drop relref94 } 75. if `1' == 94 { drop relref95 } 76. if `1' >= 94 { replace veteran = . if veteran < 0 77. replace peinusyr = . if peinusyr < 0 78. replace penatvty = . if penatvty < 0 79. replace pemntvty = . if pemntvty < 0 80. replace pefntvty = . if pefntvty < 0 81. replace prcitshp = . if prcitshp < 0 82. replace prcitflg = . if prcitflg < 0 } 83. if `1' > 93 { replace ethnic = . if ethnic < 0 } 84. . * Employment . if `1' >= 94 { 85. replace lfsr94 = . if lfsr94 <0 86. replace occ80 = . if occ80 <0 87. replace ind80 = . if ind80 < 10 88. replace class94 = . if class94<0 } 89. #delimit ; delimiter now ; . if `1' >=83 { generate int docc80=occ80; 90. 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}; 91. if `1'<=82{ > replace dind=ind70 ; 92. 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 } ; 93. if `1' <=93 & `1' >=83 {replace dind=ind80; 94. 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}; 95. if `1' >= 94 {replace dind=ind80; 96. 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 }; 97. #delimit cr delimiter now cr . * Wages (If earnings are 0, then wage rate is missing, not zero). . replace paidhr = . if paidhr <=0 98. replace paidhre = . if paidhre <=0 99. replace earnhr = . if earnhr <=0 100. replace earnhre = . if earnhre <=0 101. replace earnwke = . if earnwke < 0 102. if `1' < 89 {replace eligible = 2 if eligible==. } 103. if `1' >= 89 {replace eligible = 2 if eligible==0 104. replace eligible = . if eligible < 0 } 105. if `1' < 89 {replace I25a = 0 if I25a ==. 106. replace I25b = 0 if I25b ==. 107. replace I25c = 0 if I25c ==. 108. replace I25d = 0 if I25d ==.} 109. if `1' >= 94 {replace eligible = 0 if eligible ==. 110. replace I25a = 0 if I25a <= 3 111. replace I25b = 0 if I25b <= 3 112. replace earnhre = . if earnhre ==1 113. replace uhourse = . if lfsr94 >2 | lfsr94 <1 114. replace lfsr94 = . if lfsr94 < 0 } 115. . * Hours, Unions . if `1' >= 94 { 116. replace reason94 = . if reason94< 0 117. replace absent94 = . if absent94< 0 118. replace studftpt = . if studftpt< 0 119. replace ftpt94 = . if ftpt94 < 0 120. replace hourslw = . if hourslw < 0 121. replace hourslw = 99 if hourslw >99 & hourslw != . 122. replace uhourse = . if uhourse < 0 123. replace why3594 = . if why3594 < 0 124. replace unionmme = . if unionmme< 0 125. replace unioncov = . if unioncov< 0 } 126. . * Save and exit . ! /bin/rm -f /home/data/morg/raw/temp/morg`1'.dta 127. compress 128. save /home/data/morg/raw/temp/morg`1',old 129. summarize 130. clear 131. ! /bin/rm -f aef.dct /tmp/aef.raw 132. 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 79 79_83 . *aef2 80 79_83 . *aef2 81 79_83 . *aef2 82 79_83 . *aef2 83 79_83 . *aef2 84 84_88 . *aef2 85 84_88 . *aef2 86 84_88 . *aef2 87 84_88 . *aef2 88 84_88 . *aef2 89 89_93 . *aef2 90 89_93 . *aef2 91 89_93 . *aef2 92 89_93 . *aef2 93 89_93 . *aef2 94 94_97 . *aef2 95 94_97 . aef2 96 94_97 (77545 real changes made, 77545 to missing) (200311 real changes made, 200311 to missing) (0 real changes made) (276310 real changes made) (275120 real changes made) (823 real changes made, 823 to missing) (106115 real changes made, 106115 to missing) (77890 real changes made, 77890 to missing) (259704 real changes made, 259704 to missing) (167660 real changes made, 167660 to missing) (77890 real changes made, 77890 to missing) (180515 real changes made, 180515 to missing) (0 real changes made) (0 real changes made) (1246 real changes made, 1246 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) (0 real changes made) (1246 real changes made, 1246 to missing) (85414 real changes made, 85414 to missing) (85414 real changes made, 85414 to missing) (85414 real changes made, 85414 to missing) (85414 missing values generated) (192442 changes made) dind was byte now int (277856 real changes made, 85414 to missing) (192442 changes made) (125666 real changes made, 125666 to missing) (0 real changes made) (183931 real changes made, 183931 to missing) (0 real changes made) (0 real changes made) (125667 real changes made) (0 real changes made) (0 real changes made) (104435 real changes made) (125666 real changes made) (0 real changes made) (104435 real changes made, 104435 to missing) (0 real changes made) (263578 real changes made, 263578 to missing) (269658 real changes made, 269658 to missing) (258235 real changes made, 258235 to missing) (1246 real changes made, 1246 to missing) (112633 real changes made, 112633 to missing) (87 real changes made) (14986 real changes made, 14986 to missing) (233851 real changes made, 233851 to missing) (125666 real changes made, 125666 to missing) (147736 real changes made, 147736 to missing) uhourse was int now byte dind was int now byte docc80 was int now byte file /home/data/morg/raw/temp/morg96.dta saved Variable | Obs Mean Std. Dev. Min Max ---------+----------------------------------------------------- intmonth | 277856 6.536602 3.458798 1 12 minsamp | 277856 5.99214 1.999988 4 8 state | 277856 53.27262 26.07671 11 95 centcity | 171741 5.516743 2.985079 1 74 msafips | 199966 4507.596 2519.146 80 9360 cmsacode | 97341 53.51734 26.82367 7 97 smsastat | 277033 1.237863 .4257758 1 2 smsa93 | 0 icntcity | 18152 1.190227 .5380229 1 4 hhid | 0 sex | 277856 1.52967 .4991198 1 2 veteran | 276610 5.586711 1.209324 1 6 grade92 | 277856 39.52208 2.855723 31 46 why3594 | 44005 14.70644 6.872433 1 23 class94 | 192442 4.129343 1.197261 1 8 unioncov | 130120 1.979427 .1419514 1 2 studftpt | 19621 1.092605 .2898853 1 2 relref95 | 277856 2.925184 2.925088 1 18 age | 277856 44.18312 18.13822 16 90 marital | 277856 3.161123 2.593398 1 7 race | 277856 1.231033 .6462387 1 4 hourslw | 165211 39.15797 14.243 1 99 reason94 | 14278 5.582785 3.12791 1 13 absent94 | 8198 6.129178 3.387722 4 14 ind80 | 192442 580.1935 276.8235 10 991 occ80 | 192442 366.6342 248.9975 4 905 uhourse | 158435 39.1856 11.88232 0 99 paidhre | 152190 1.382436 .4859839 1 2 unionmme | 152190 1.854984 .3521182 1 2 ethnic | 277856 7.66375 1.312874 1 10 lfsr94 | 276610 2.779516 2.343772 1 7 ftpt94 | 276610 2.737265 2.50568 1 12 dind | 192442 31.12334 13.49404 1 52 eligible | 277856 1.452274 .4977179 1 2 earnhre | 93925 1006.895 588.2619 10 9975 earnwke | 152190 508.9036 371.295 0 1923 weight | 277856 2165.769 1046.214 0 12347.75 earnwt | 277856 8697.715 4174.887 246.4069 49442.13 I25a | 277856 .1833108 2.523838 0 43 I25b | 277856 2.322491 9.589426 0 42 penatvty | 277856 79.63104 72.25778 57 555 pemntvty | 277856 87.7158 80.41492 57 555 pefntvty | 277856 88.02839 80.40359 57 555 prcitshp | 277856 1.385102 1.109077 1 5 prcitflg | 277856 .1667842 2.1367 0 41 peinusyr | 277856 .8424112 2.705196 0 14 hrlonglk | 277856 1.990592 .1368469 0 2 lineno | 277856 1.737882 1.013409 1 16 year | 277856 96 0 96 96 docc80 | 192442 22.55874 12.71377 1 46 . *aef2 97 94_97 . *aef2 98 98 . *aef2 99 98 . end of do-file . :q unrecognized command: : invalid command name r(199); . exit,clear