---------------------------------------------------------------------------------------------------- log: c:\paulafiles\teach\harris\practicum_f09\employment_spec_prog05.txt log type: text opened on: 16 Oct 2009, 16:38:39 . ************************************************************************************** ; . * read in file with list of desired industries (sectors) and save as STATA dataset * ; . * .....ultimately will merge this file to select only the industries we want * ; . ************************************************************************************** ; . insheet using "c:\paulafiles\teach\harris\practicum_f09\industry_list_01.csv", names; (4 vars, 20 obs) . sort industry; . save tempdata, replace; file tempdata.dta saved . clear; . ********************************************************************** ; . * read in file of employment by industry and take a look at it * ; . ********************************************************************** ; . insheet using "c:\paulafiles\teach\harris\practicum_f09\table_p49_census_2000_laplata_co_r > ev02.csv" , names; (6 vars, 54 obs) . describe, fullnames; Contains data obs: 54 vars: 6 size: 5,346 (99.9% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- industry str84 %84s gender str6 %9s employment int %8.0g v4 byte %8.0g v5 byte %8.0g v6 str1 %9s ------------------------------------------------------------------------------- Sorted by: Note: dataset has changed since last saved . ***************************************************************** ; . * create short industry name and an industry "order" number * ; . ***************************************************************** ; . generate short_industry = substr(industry,1,20); . summarize; Variable | Obs Mean Std. Dev. Min Max -------------+-------------------------------------------------------- industry | 0 gender | 0 employment | 54 1109.407 2159.83 0 12212 v4 | 0 v5 | 0 -------------+-------------------------------------------------------- v6 | 0 short_indu~y | 0 . list short_industry gender employment; +------------------------------------------+ | short_industry gender employ~t | |------------------------------------------| 1. | Total Male 12212 | 2. | Agriculture, forestr Male 780 | 3. | Agriculture, forestr Male 523 | 4. | Mining Male 257 | 5. | Construction Male 2088 | |------------------------------------------| 6. | Manufacturing Male 621 | 7. | Wholesale trade Male 378 | 8. | Retail trade Male 1408 | 9. | Transportation and w Male 814 | 10. | Transportation and w Male 486 | |------------------------------------------| 11. | Utilities Male 328 | 12. | Information Male 226 | 13. | Finance, insurance, Male 544 | 14. | Finance and insuranc Male 212 | 15. | Real estate and rent Male 332 | |------------------------------------------| 16. | Professional, scient Male 1124 | 17. | Professional, scient Male 797 | 18. | Management of compan Male 2 | 19. | Administrative and s Male 325 | 20. | Educational, health Male 1414 | |------------------------------------------| 21. | Educational services Male 897 | 22. | Health care and soci Male 517 | 23. | Arts, entertainment, Male 1664 | 24. | Arts, entertainment, Male 343 | 25. | Accommodation and fo Male 1321 | |------------------------------------------| 26. | Other services (exce Male 543 | 27. | Public administratio Male 608 | 28. | Total Female 10778 | 29. | Agriculture, forestr Female 249 | 30. | Agriculture, forestr Female 207 | |------------------------------------------| 31. | Mining Female 42 | 32. | Construction Female 214 | 33. | Manufacturing Female 329 | 34. | Wholesale trade Female 128 | 35. | Retail trade Female 1380 | |------------------------------------------| 36. | Transportation and w Female 333 | 37. | Transportation and w Female 239 | 38. | Utilities Female 94 | 39. | Information Female 265 | 40. | Finance, insurance, Female 910 | |------------------------------------------| 41. | Finance and insuranc Female 519 | 42. | Real estate and rent Female 391 | 43. | Professional, scient Female 905 | 44. | Professional, scient Female 702 | 45. | Management of compan Female 0 | |------------------------------------------| 46. | Administrative and s Female 203 | 47. | Educational, health Female 3560 | 48. | Educational services Female 1719 | 49. | Health care and soci Female 1841 | 50. | Arts, entertainment, Female 1631 | |------------------------------------------| 51. | Arts, entertainment, Female 442 | 52. | Accommodation and fo Female 1189 | 53. | Other services (exce Female 471 | 54. | Public administratio Female 403 | +------------------------------------------+ . **************************************************************************************** ; . * use STATAs reshape command in some fashion...data are long but need to be wide * ; . **************************************************************************************** ; . reshape wide employment, i(industry) j(gender) string; (note: j = Female Male) Data long -> wide ----------------------------------------------------------------------------- Number of obs. 54 -> 27 Number of variables 7 -> 7 j variable (2 values) gender -> (dropped) xij variables: employment -> employmentFemale employmentMale ----------------------------------------------------------------------------- . describe, fullnames; Contains data obs: 27 vars: 7 size: 3,105 (99.9% of memory free) ------------------------------------------------------------------------------- storage display value variable name type format label variable label ------------------------------------------------------------------------------- industry str84 %84s employmentFemale int %8.0g Female employment employmentMale int %8.0g Male employment v4 byte %8.0g v5 byte %8.0g v6 str1 %9s short_industry str20 %20s ------------------------------------------------------------------------------- Sorted by: industry Note: dataset has changed since last saved . list short_industry employmentMale employmentFemale; +--------------------------------------------+ | short_industry emp~Male emp~male | |--------------------------------------------| 1. | Accommodation and fo 1321 1189 | 2. | Administrative and s 325 203 | 3. | Agriculture, forestr 523 207 | 4. | Agriculture, forestr 780 249 | 5. | Arts, entertainment, 343 442 | |--------------------------------------------| 6. | Arts, entertainment, 1664 1631 | 7. | Construction 2088 214 | 8. | Educational services 897 1719 | 9. | Educational, health 1414 3560 | 10. | Finance and insuranc 212 519 | |--------------------------------------------| 11. | Finance, insurance, 544 910 | 12. | Health care and soci 517 1841 | 13. | Information 226 265 | 14. | Management of compan 2 0 | 15. | Manufacturing 621 329 | |--------------------------------------------| 16. | Mining 257 42 | 17. | Other services (exce 543 471 | 18. | Professional, scient 797 702 | 19. | Professional, scient 1124 905 | 20. | Public administratio 608 403 | |--------------------------------------------| 21. | Real estate and rent 332 391 | 22. | Retail trade 1408 1380 | 23. | Total 12212 10778 | 24. | Transportation and w 486 239 | 25. | Transportation and w 814 333 | |--------------------------------------------| 26. | Utilities 328 94 | 27. | Wholesale trade 378 128 | +--------------------------------------------+ . ************************************************************ ; . * now compute total employment by industry * ; . ************************************************************ ; . generate employment = employmentMale + employmentFemale; . ******************************************************************************** ; . * keep only the 20 industries that correspond to published report * ; . * ....note....report has only 19 (it combines two), but this will be close * ; . * enough to verify figures * ; . ******************************************************************************** ; . *generate ind_num = _n; . sort industry; . merge industry using tempdata; (note: v4 is str1 in using data but will be byte now) . tabulate _merge; _merge | Freq. Percent Cum. ------------+----------------------------------- 1 | 7 25.93 25.93 3 | 20 74.07 100.00 ------------+----------------------------------- Total | 27 100.00 . /* keep only industries that are on my list */ > keep if _merge == 3; (7 observations deleted) . sort ind_num; . list short_industry employment ind_num ; +-------------------------------------------+ | short_industry employ~t ind_num | |-------------------------------------------| 1. | Agriculture, forestr 730 1 | 2. | Mining 299 2 | 3. | Construction 2302 3 | 4. | Manufacturing 950 4 | 5. | Wholesale trade 506 5 | |-------------------------------------------| 6. | Retail trade 2788 6 | 7. | Transportation and w 725 7 | 8. | Utilities 422 8 | 9. | Information 491 9 | 10. | Finance and insuranc 731 10 | |-------------------------------------------| 11. | Real estate and rent 723 11 | 12. | Professional, scient 1499 12 | 13. | Management of compan 2 13 | 14. | Administrative and s 528 14 | 15. | Educational services 2616 15 | |-------------------------------------------| 16. | Health care and soci 2358 16 | 17. | Arts, entertainment, 785 17 | 18. | Accommodation and fo 2510 18 | 19. | Other services (exce 1014 19 | 20. | Public administratio 1011 20 | +-------------------------------------------+ . ****************************************************************** ; . * print out data and confirm we have correct total employment * ; . ****************************************************************** ; . egen all_employment = sum(employment); . list short_industry employment all_employment; +--------------------------------------------+ | short_industry employ~t all_em~t | |--------------------------------------------| 1. | Agriculture, forestr 730 22990 | 2. | Mining 299 22990 | 3. | Construction 2302 22990 | 4. | Manufacturing 950 22990 | 5. | Wholesale trade 506 22990 | |--------------------------------------------| 6. | Retail trade 2788 22990 | 7. | Transportation and w 725 22990 | 8. | Utilities 422 22990 | 9. | Information 491 22990 | 10. | Finance and insuranc 731 22990 | |--------------------------------------------| 11. | Real estate and rent 723 22990 | 12. | Professional, scient 1499 22990 | 13. | Management of compan 2 22990 | 14. | Administrative and s 528 22990 | 15. | Educational services 2616 22990 | |--------------------------------------------| 16. | Health care and soci 2358 22990 | 17. | Arts, entertainment, 785 22990 | 18. | Accommodation and fo 2510 22990 | 19. | Other services (exce 1014 22990 | 20. | Public administratio 1011 22990 | +--------------------------------------------+ . ******************************* ; . * compute employment shares * ; . ******************************* ; . generate share = employment/all_employment; . format share %8.3f; . list short_industry employment share; +-----------------------------------------+ | short_industry employ~t share | |-----------------------------------------| 1. | Agriculture, forestr 730 0.032 | 2. | Mining 299 0.013 | 3. | Construction 2302 0.100 | 4. | Manufacturing 950 0.041 | 5. | Wholesale trade 506 0.022 | |-----------------------------------------| 6. | Retail trade 2788 0.121 | 7. | Transportation and w 725 0.032 | 8. | Utilities 422 0.018 | 9. | Information 491 0.021 | 10. | Finance and insuranc 731 0.032 | |-----------------------------------------| 11. | Real estate and rent 723 0.031 | 12. | Professional, scient 1499 0.065 | 13. | Management of compan 2 0.000 | 14. | Administrative and s 528 0.023 | 15. | Educational services 2616 0.114 | |-----------------------------------------| 16. | Health care and soci 2358 0.103 | 17. | Arts, entertainment, 785 0.034 | 18. | Accommodation and fo 2510 0.109 | 19. | Other services (exce 1014 0.044 | 20. | Public administratio 1011 0.044 | +-----------------------------------------+ . ************************************************************* ; . * compute Herfindahl measure of employment specialization * ; . ************************************************************* ; . generate share_sq = share*share; . egen sum_sq = sum(share_sq); . generate herf = sum_sq*10000; . list ind_num short_industry employment share share_sq sum_sq herf; +-----------------------------------------------------------------------------------+ | ind_num short_industry employ~t share share_sq sum_sq herf | |-----------------------------------------------------------------------------------| 1. | 1 Agriculture, forestr 730 0.032 .0010082 .0771009 771.009 | 2. | 2 Mining 299 0.013 .0001691 .0771009 771.009 | 3. | 3 Construction 2302 0.100 .0100261 .0771009 771.009 | 4. | 4 Manufacturing 950 0.041 .0017075 .0771009 771.009 | 5. | 5 Wholesale trade 506 0.022 .0004844 .0771009 771.009 | |-----------------------------------------------------------------------------------| 6. | 6 Retail trade 2788 0.121 .0147064 .0771009 771.009 | 7. | 7 Transportation and w 725 0.032 .0009945 .0771009 771.009 | 8. | 8 Utilities 422 0.018 .0003369 .0771009 771.009 | 9. | 9 Information 491 0.021 .0004561 .0771009 771.009 | 10. | 10 Finance and insuranc 731 0.032 .001011 .0771009 771.009 | |-----------------------------------------------------------------------------------| 11. | 11 Real estate and rent 723 0.031 .000989 .0771009 771.009 | 12. | 12 Professional, scient 1499 0.065 .0042513 .0771009 771.009 | 13. | 13 Management of compan 2 0.000 7.57e-09 .0771009 771.009 | 14. | 14 Administrative and s 528 0.023 .0005275 .0771009 771.009 | 15. | 15 Educational services 2616 0.114 .0129478 .0771009 771.009 | |-----------------------------------------------------------------------------------| 16. | 16 Health care and soci 2358 0.103 .0105199 .0771009 771.009 | 17. | 17 Arts, entertainment, 785 0.034 .0011659 .0771009 771.009 | 18. | 18 Accommodation and fo 2510 0.109 .0119198 .0771009 771.009 | 19. | 19 Other services (exce 1014 0.044 .0019454 .0771009 771.009 | 20. | 20 Public administratio 1011 0.044 .0019339 .0771009 771.009 | +-----------------------------------------------------------------------------------+ . **************************************** ; . * clean up and get out * ; . **************************************** ; . clear; . log close; log: c:\paulafiles\teach\harris\practicum_f09\employment_spec_prog05.txt log type: text closed on: 16 Oct 2009, 16:38:43 ----------------------------------------------------------------------------------------------------