------------------------------------------------------------------------------- log: /disk/nber10/SCCS/morg/sources/annual2003_scalar.log log type: text opened on: 23 Feb 2004, 14:47:41 . set memory 1000m (1024000k) . set more 1 . *primary family and child variables added 2000-04-20 by Jean Roth, jroth@nber > .org . *Y2K compliance by Jean Roth, jroth@nber.org, 2001-01-15 . *Imputed highest grade completed, ihigrdc, added by Jean Roth, jroth@nber.org > , 2003-01-20 . *Stata 8 compliance by Jean Roth, jroth@nber.org, 2003-02-28 . *matching variables added by Jean Roth, jroth@nber.org, 2003-02-12 . ! /bin/rm -f /tmp/aef.raw aef.dct dcthead . * run with stata6 -p0 do annual2002 to get Stata 5 format . * run with nohup stata -b do annual2002 & to run in batch mode . ! echo >dcthead dictionary using /tmp/aef.raw . program define aef2 1. * '-A' are missing value indicators in the earlier files. . display "defining scalars" 2. tempname year 3. scalar `year' = `1' 4. local `yy' = `2' 5. display year " year " yy " yy" 6. if `year' <= 1993 { 7. !zcat /home/data/morg/raw/morg`yy'.Z |tr "\-A" " " >/tmp/aef.raw 8. } 9. if `year' >= 1994 { 10. display "zcat" 11. !zcat /home/data/morg/raw/morg`yy'.Z >/tmp/aef.raw 12. } 13. ! cat /home/data/morg/sources/dcthead /home/data/morg/sources/aef`3'.dbd > > ./aef.dct 14. quietly infile using aef if age>15&age!=. 15. #delimit cr delimiter now cr . . * Miscellaneous (record keeping) variables . if `1' == 1994 { 16. replace hhid = hhid94 17. drop hhid94 18. } 19. if `1'== 1995 { 20. replace hhid = hhid94 if intmonth<9 21. drop hhid94 22. } 23. if inlist( `1', 1996 , 1997 ) { 24. drop hhid94 25. } 26. * Geography . display "Geography" 27. generate int year = `1' 28. if `1' >= 1996 { 29. replace smsa93 = . if smsa93<2 30. } 31. display "smsasize = . if smsasize <=0" 32. replace smsasize = . if smsasize <=0 33. if `1' == 1995 { 34. replace smsastat = smsa995 if intmonth>8 35. replace icntcity = icntct94 if intmonth<9 36. replace centcity = centcitx if intmonth<9 37. replace smsa93 = . if intmonth>=9 & smsa93<2 38. replace smsa93 = . if intmonth<9 39. drop pmsarank 40. generate smsa80 = smsasize if intmonth < 10 41. } 42. display "inlisting 96 97" 43. if inlist( `1', 1996 , 1997 ) { 44. replace smsastat = smsa995 45. } 46. display "replace smsastat = . if smsastat==3 | smsastat<0" 47. replace smsastat = . if smsastat==3 | smsastat<0 48. if `1' == 1994 { 49. drop smsa93 50. replace centcity = centcitx 51. replace icntcity = icntct94 52. replace pmsarank = . if intmonth > 3 53. replace pmsarank = . if pmsarank <= 0 54. replace cmsarank = . if intmonth > 3 55. } 56. if inlist( `1', 1996 , 1997 ) { 57. drop pmsarank 58. } 59. if `1' >= 1994 & `1' <= 1997 { 60. drop centcitx icntct94 smsa995 61. } 62. if `1' >= 1994 { 63. replace hurespli =. if hurespli <0 64. replace peinusyr = . if peinusyr < 0 65. } 66. display "replace centcity = . if centcity==4 | centcity<=0" 67. replace centcity = . if centcity==4 | centcity<=0 68. if `1' >= 1986 & `1' < 1994 { 69. replace pmsarank = . if pmsarank<=0 70. } 71. if `1' >= 1995 & `1' <= 1997 { 72. drop cmsarank 73. } 74. if `1' >= 1986 { 75. replace icntcity = . if icntcity<=0 76. } 77. if `1' > 1984 & `1' < 1995 { 78. replace cmsarank = . if cmsarank<=0 79. } 80. if `1' >= 1989 { 81. replace msafips = . if msafips <=0 82. replace cmsacode = . if cmsacode<=0 83. } 84. if `1' == 1983 { 85. drop docc70 occ70 86. } 87. if `1' == 1985 { 88. replace smsarank = . if intmonth > 9 89. } 90. if `1' == 1984 { 91. display "drop icntcity pmsarank cmsarank" 92. drop icntcity pmsarank cmsarank 93. } 94. if `1' == 1985 & intmonth < 10 { 95. drop icntcity pmsarank cmsarank 96. } 97. if `1' == 1994 { 98. replace cmsarank = . if intmonth>3 99. } 100. display "replace smsasize=. if smsasize<=0" 101. **should line below be commented out??? . replace smsasize=. if smsasize<=0 102. if `1' < 1985 { 103. display "generate byte smsa70 = smsasize" 104. generate byte smsa70 = smsasize 105. } 106. if `1' > 1985 & `1' < 1995 { 107. generate byte smsa80 = smsasize 108. } 109. if `1' == 1985 { 110. generate byte smsa70 = smsasize if intmonth<10 111. } 112. if `1' == 1985 { 113. generate byte smsa80 = smsasize if intmonth>9 114. } 115. display "drop smsasize" 116. drop smsasize 117. if `1' > 1985 & `1' < 1989 { 118. drop smsarank 119. } 120. if `1' < 1983 { 121. display "drop unioncov unionmme occ80 ind80" 122. drop unioncov unionmme occ80 ind80 123. } 124. . * Demography . display "Demography" 125. if `1' > 1983 & `1' < 1994 { 126. replace ownchild = . if ownchild ==0 127. replace ownchild = ownchild - 1 128. generate int ch613=chldpres 129. generate int ch1417=chldpres 130. } 131. display "if `1' > 1983 & `1' < 1989 {" 132. if `1' > 1983 & `1' < 1989 { 133. generate int ch05= chldpres 134. recode ch05 (4 6/8 = 1) (0/3 5 = 0) 135. recode ch613 (3 5 7/8 = 1) (0/2 4 6 = 0) 136. recode ch1417 (2 5/6 8 =1) (0/1 3/4 7 = 0) 137. } 138. if `1' > 1988 & `1' < 1994 { 139. display "if `1' > 1988 & `1' < 1994 {" 140. generate int ch02 = chldpres 141. generate int ch35 = chldpres 142. recode ch02 (2 6/8 12/14 16 = 1) (0/1 3/5 9/11 15 = 0) 143. recode ch35 (3 6 9/10 12/13 15/16 = 1) (0/2 4/5 7/8 11 14 = 0) 144. recode ch613 (4 7 9 11/12 14/16 = 1) (0/3 5/6 8 10 13 = 0) 145. recode ch1417 (5 8 10/11 13/16 = 1) (0/4 6/7 9 12 = 0 ) 146. generate int ch05 = ch02 147. replace ch05 = ch35 if ch35 == 1 148. label variable ch02 "Children 0-2" 149. label variable ch35 "Children 3-5" 150. } 151. if `1' > 1983 & `1' < 1994 { 152. display "if `1' > 1983 & `1' < 1994 {" 153. label variable ch05 "Children 0-5" 154. label variable ch613 "Children 6-13" 155. label variable ch1417 "Children 6-17" 156. } 157. if `1' == 1998 { 158. drop ownchild chldpres 159. } 160. if `1' >= 1999 { 161. replace ownchild = . if ownchild < 0 162. replace chldpres = . if chldpres < 0 163. generate int ch02 = chldpres 164. generate int ch35 = chldpres 165. generate int ch613 = chldpres 166. generate int ch1417 = chldpres 167. recode ch02 (1 5/7 11/13 15 = 1) (0 2/4 8/10 14 = 0) 168. recode ch35 (2 5 8/9 11/12 14/15 = 1) (0/1 3/4 6/7 10 13 =0) 169. recode ch613 (3 6 8 10/11 13/15 = 1) (0/2 4/5 7 9 12 = 0) 170. recode ch1417 (4 7 9/10 12/15 = 1) (0/3 5/6 8 11 = 0) 171. generate int ch05 = ch02 172. replace ch05 = ch35 if ch35 == 1 173. } 174. . if `1' == 1999 { 175. replace ownchild = . if intmonth < 10 176. replace chldpres = . if intmonth < 10 177. replace ch613 = . if intmonth < 10 178. replace ch1417 = . if intmonth < 10 179. replace ch05 = . if intmonth < 10 180. replace ch02 = . if intmonth < 10 181. replace ch35 = . if intmonth < 10 182. } 183. if `1' > 1988 & `1' < 1992 { 184. drop grade92 185. } 186. if `1' < 1989 { 187. replace gradeat = gradeat - 1 188. replace marital = 7 if marital==5 189. } 190. if `1' > 1991 { 191. replace grade92 = . if grade92 < 0 192. } 193. if `1' >= 1998 { 194. replace ged = . if ged < 0 195. replace gedhigr = . if gedhigr < 0 196. replace yrcoll = . if yrcoll < 0 197. replace grprof = . if grprof < 0 198. replace gr6cor = . if gr6cor < 0 199. replace ms123 = . if ms123 < 0 200. generate double ihigrdc = . 201. label var ihigrdc "Imputed highest grade completed" 202. replace ihigrdc = 0 if grade92==31 203. replace ihigrdc = 2.5 if grade92==32 204. replace ihigrdc = 5.5 if grade92==33 205. replace ihigrdc = 7.5 if grade92==34 206. replace ihigrdc = 9 if grade92==35 207. replace ihigrdc =10 if grade92==36 208. replace ihigrdc =11 if grade92==37 209. replace ihigrdc =12 if grade92==38 210. replace ihigrdc = 0 if grade92==39 & ged==2 & gedhigr==1 211. replace ihigrdc = 2.5 if grade92==39 & ged==2 & gedhigr==2 212. replace ihigrdc = 5.5 if grade92==39 & ged==2 & gedhigr==3 213. replace ihigrdc = 7.5 if grade92==39 & ged==2 & gedhigr==4 214. replace ihigrdc = 9 if grade92==39 & ged==2 & gedhigr==5 215. replace ihigrdc = 10 if grade92==39 & ged==2 & gedhigr==6 216. replace ihigrdc = 11 if grade92==39 & ged==2 & gedhigr==7 217. replace ihigrdc = 12 if grade92==39 & ged==2 & gedhigr==8 218. replace ihigrdc = 12 if ged==1 219. replace ihigrdc = 12 if grade92>=40 & grade92<=42 & yrcoll==1 220. replace ihigrdc = 13 if grade92>=40 & grade92<=42 & yrcoll==2 221. replace ihigrdc = 14 if grade92>=40 & grade92<=42 & yrcoll==3 222. replace ihigrdc = 15 if grade92>=40 & grade92<=42 & yrcoll==4 223. replace ihigrdc = 16 if grade92>=40 & grade92<=42 & yrcoll==5 224. replace ihigrdc = 16 if grade92==43 & grprof==2 225. replace ihigrdc = 17 if grade92==43 & gr6cor==2 226. replace ihigrdc = 18 if grade92==43 & gr6cor==1 227. replace ihigrdc = 17 if grade92==44 & ms123==1 228. replace ihigrdc = 18 if grade92==44 & ms123>=2 & ms123<. 229. replace ihigrdc = 18 if grade92==45 | grade92==46 230. } 231. if inlist( `1', 1992 , 1993 ) { 232. drop gradecp gradeat 233. } 234. if `1' == 1995 { 235. replace relref94 = . if intmonth > 2 236. replace relref95 = . if intmonth < 3 237. } 238. if inlist( `1', 1996 , 1997 ) { 239. drop relref94 240. } 241. if `1' == 1994 { 242. drop relref95 243. } 244. if `1' >= 1994 { 245. replace veteran = . if veteran < 0 246. replace penatvty = . if penatvty < 0 247. replace pemntvty = . if pemntvty < 0 248. replace pefntvty = . if pefntvty < 0 249. replace prcitshp = . if prcitshp < 0 250. replace prcitflg = . if prcitflg < 0 251. } 252. if `1' > 1989 { 253. replace ethnic = . if ethnic < 0 254. replace ethnic = . if ethnic >= 10 255. } 256. . * Employment . display "Employment" 257. if `1' >= 1994 { 258. replace occ80 = . if occ80 <0 259. replace ind80 = . if ind80 < 10 260. replace class94 = . if class94<0 261. } 262. #delimit ; delimiter now ; . ; . display "docc80" ; 263. if `1' >= 1983 { > display "generate int docc80=occ80;"; 264. generate int docc80=occ80; 265. display "recode docc80"; 266. 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=1 > 2) > (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); 267. }; 268. display "dind"; 269. gen byte dind = . ; 270. if `1'<= 1982 { > display "`1' <= 1982: creating dind from ind70"; 271. replace dind=ind70 ; 272. 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) ; 273. } ; 274. if `1' <=1991 & `1' >=1983 { > display "replacing dind for `1': `1' <=1991 & `1' >=1983"; 275. replace dind=ind80; 276. recode > dind (12/29=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) > (30/32=46) (900/932=52) (991=51); 277. } ; 278. if `1' >= 1992 & `1' <= 2002 { > display "replacing dind for `1': `1' >= 1992 & `1' <= 2002 "; 279. replace dind=ind80; 280. 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) ; 281. }; 282. if `1' >= 2003 { > display "replacing dind for `1' >= 2003 " ; 283. replace dind = ind02; 284. recode > dind (170/180 290=1) (190/280=2) (370/490=3) (770=4) (2470/2590=5) > (2670/2990=6) (3070/3290=7) (3360/3390=8) (3470 3490=9) (3570/3690=10) > (3770/3870=11) (3890=12) (3960/3990=13) (1070/1290=14) (1370 1390=15) > (1470/1790=16) (1870/1990=17) (2070 2090=18) (2170/2290=19) (2370/2390=20 > ) > (4070/4590=21) (4670/5790=22) (6070/6390=23) (570/690=24) (6470/6490=25) > (6570 6590=26) (6670=27) (6675=28) (6680 6690=29) (6692 6695=30) > (6770 6780=31) (6870/6970=32) (6990=33) (7070=34) (7080/7190=35) > (7270/7490=36) (7570=37) (7580/7780=38) (7790=39) (7860/7890=40) > (8190=41) (7970/8180 8270 8290=42) (8370/8470=43) (8560/8590=44) (8660 86 > 70=45) > (8680 8690=46) (8770/8890=47) (8970/9090=48) (9160/9190=49) (9290=50) > (9370/9590=51) (9890=52) ; 285. tab dind if blsdind != dind ; 286. tab blsdind if blsdind != dind ; 287. tab dind blsdind if blsdind != dind ; 288. } ; 289. #delimit cr delimiter now cr . #delimit cr delimiter now cr . * Wages (If earnings are 0, then wage rate is missing, not zero). . display "Wages" 290. replace paidhr = . if paidhr <=0 291. replace paidhre = . if paidhre <=0 292. replace earnhr = . if earnhr <=0 293. replace earnhre = . if earnhre <=0 294. replace earnwke = . if earnwke < 0 295. if `1' < 1989 { 296. replace eligible = 2 if eligible == . 297. } 298. if `1' >= 1989 { 299. replace eligible = 2 if eligible <= 0 300. } 301. if `1' < 1989 { 302. replace I25a = 0 if I25a ==. 303. replace I25b = 0 if I25b ==. 304. replace I25c = 0 if I25c ==. 305. replace I25d = 0 if I25d ==. 306. } 307. if `1' >= 1994 { 308. replace I25a = 0 if I25a <= 3 309. replace I25b = 0 if I25b <= 3 310. *replace I25a = . if I25a < 0 . *replace I25b = . if I25b < 0 . replace earnhre = . if earnhre ==1 311. replace uhourse = . if lfsr94 >2 | lfsr94 <1 312. replace lfsr94 = . if lfsr94 < 0 313. } 314. if `1' >= 1996 { 315. replace I25c = . if I25c < 0 316. replace I25d = . if I25d < 0 317. } 318. if `1' == 1995 { 319. replace I25c = . if I25c < 0 320. replace I25d = . if I25d < 0 321. replace I25c = . if intmonth < 9 322. replace I25d = . if intmonth < 9 323. } 324. if `1' == 1994 { 325. drop I25c I25d 326. } 327. * Hours, Unions . display "Hours, Unions" 328. if `1' >= 1994 { 329. replace reason94 = . if reason94< 0 330. replace absent94 = . if absent94< 0 331. replace studftpt = . if studftpt< 0 332. replace schenr = . if schenr < 0 333. replace schlvl = . if schlvl < 0 334. replace ftpt94 = . if ftpt94 < 0 335. replace hourslw = . if hourslw < 0 336. replace hourslw = 99 if hourslw >99 & hourslw != . 337. replace uhourse = . if uhourse < 0 338. replace why3594 = . if why3594 < 0 339. replace unionmme = . if unionmme< 0 340. replace unioncov = . if unioncov< 0 341. } 342. quietly describe 343. display "obs " r(N) 344. ** Revised Census 2000-based Weights . if inlist( `year', 2000 , 2001 , 2002 ) { 345. gen id = _n 346. local rwlist qstnum intmonth year occurnum 347. sort `rwlist' 348. quietly describe 349. display "total obs pre-revise `year' " r(N) 350. save /homes/data/morg/annual/rw/annual, replace 351. rw `yy' jan 1 352. rw `yy' feb 2 353. rw `yy' mar 3 354. rw `yy' apr 4 355. rw `yy' may 5 356. rw `yy' jun 6 357. rw `yy' jul 7 358. rw `yy' aug 8 359. rw `yy' sep 9 360. rw `yy' oct 10 361. rw `yy' nov 11 362. rw `yy' dec 12 363. local monlist feb mar apr may jun jul aug sep oct nov dec 364. clear 365. display "using jan" 366. use /homes/data/morg/annual/rw/jan 367. foreach mon in `monlist' { 368. append using /home/data/morg/annual/rw/`mon' 369. } 370. quietly describe 371. display "total obs post-revise" r(N) 372. display "start renaming" 373. rename ind80 p_ind80 374. rename neio1icd ind02 375. rename class94 pclass94 376. *rename dind p_dind . *rename nrdtind1 dind . rename docc80 p_docc80 377. rename nrdtocc1 docc80 378. rename earnwt p_earnwt 379. rename nworwgt earnwt 380. rename weight p_weight 381. display "done renaming" 382. display "drop 2000" 383. if `year' == 2000 { 384. drop neerncov neernlab 385. } 386. display "rename 2001-2002" 387. if inlist( `year' , 2001 , 2002 ) { 388. rename unioncov punionco 389. rename neerncov unioncov 390. rename unionmme punionme 391. rename neernlab unionmme 392. } 393. sort id 394. drop id _merge 395. } 396. . * Save and exit . compress 397. saveold /home/data/morg/annual/temp/morg`2'rw,replace 398. summarize 399. ! /bin/chmod a+r /home/data/morg/annual/m*.dta 400. ! /bin/chmod g+w /home/data/morg/annual/m*.dta 401. ! /bin/chgrp web /home/data/morg/annual/m*.dta 402. clear 403. ! /bin/rm -f aef.dct /tmp/aef.raw 404. end . . program rw 1. ** grab the annual file . ** keep data from the relevant month . ** sort by revised weight merge variables . ** merge using the revised weight monthly file, 'rwmonyy.dta' . ** save the merged file as 'mon' . use /homes/data/morg/annual/rw/annual 2. keep if intmonth==`3' 3. quietly describe 4. display "`2' obs " r(N) 5. local rwlist qstnum intmonth year occurnum 6. sort `rwlist' 7. merge `rwlist' using /homes/data/morg/annual/rw/rw`2'`1' 8. drop if _merge == 2 9. save /homes/data/morg/annual/rw/`2', replace 10. 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_02 . *aef2 1999 99 98_02 . aef2 2000 00 98_02 defining scalars _= invalid name r(198); end of do-file r(198); . exit