#------------------------------------------------------------------------------------------------------------------------ #FOR PROBLEMS OR QUESTIONS ABOUT THIS CODE, PLEASE EMAIL: NIOSHIOCoding@cdc.gov #2010 4-digit census occupation codes (from 2010 soc) recoded to 2018 nhis simple recodes for occupation =occ_simple #2007/2012 4-digit naics-based census industry codes recoded to 2018 nhis simple recodes for industry =ind_simple #caution: 2018 census codes used in the current american community survey have 146 new codes for occupation and 19 new industry codes. these new codes are not included in this program. #based on recodes from industry & occupation appendices in this document ftp://ftp.cdc.gov/pub/health_statistics/nchs/dataset_documentation/nhis/2018/samadult_layout.pdf #niosh nchs codes are those assigned by the niosh industry and occupation computerized coding system (nioccs)for non-paid workers and military #see https://www.cdc.gov/niosh/topics/coding/nioccsuserdocumentation.html #Basic Setup------------------------------------------------------------------------------------------------------------ setwd()#Set working directory to your data library(summarytools) library(tidyverse) iotable<- read_csv() #Read in your data #For this recode, you will need individual census occupation and industry code character variables named: #BOC_2010_OCC_CODE #BOC_2012_IND_CODE #------------------------------------------------------------------------------------------------------------------------ #2010 4-digit census occupation codes (from 2010 SOC) recoded to 2018 NHIS simple recodes for occupation =occ_simple #2007/2012 NAICS-based census industry codes recoded to 2018 NHIS simple recodes for industry =ind_simple #includes codes for 2007 since there was a one-to-one match for census codes see: # https://www.census.gov/topics/employment/industry-occupation/guidance/code-lists.html #includes industry code 2780 metal forgings and stampings, which was in the detailed recode but not the simple #includes NIOSH/NCHS non-paid worker codes and military codes see: # https://www.cdc.gov/niosh/topics/coding/nioccsuserdocumentation.html iotable$occ_simple <-ifelse(iotable$BOC_2010_OCC_CODE %in% c("0010", "0020", "0030", "0040", "0050", "0060", "0100", "0110", "0120", "0135", "0136", "0137", "0140", "0150", "0160", "0205", "0220", "0230", "0300", "0310", "0325", "0330", "0340", "0350", "0360", "0400", "0410", "0420", "0425", "0430"), "01", ifelse(iotable$BOC_2010_OCC_CODE %in% c("0500", "0510", "0520", "0530", "0540", "0565", "0600", "0630", "0640", "0650", "0700", "0710", "0725", "0726", "0735", "0740", "0800", "0810", "0820", "0830", "0840", "0850", "0860", "0900", "0910", "0930", "0940", "0950"), "02", ifelse(iotable$BOC_2010_OCC_CODE %in% c("1005", "1006", "1007", "1010", "1020", "1030", "1050", "1060", "1105", "1106", "1107", "1200", "1210", "1220", "1230", "1240"), "03", ifelse(iotable$BOC_2010_OCC_CODE %in% c("1300", "1310", "1320", "1330", "1340", "1350", "1360", "1400", "1410", "1420", "1430", "1440", "1450", "1460", "1500", "1510", "1520", "1530", "1540", "1550", "1560"), "04", ifelse(iotable$BOC_2010_OCC_CODE %in% c("1600", "1610", "1640", "1650", "1660", "1700", "1710", "1720", "1740", "1750", "1760", "1800", "1815", "1820", "1830", "1840", "1850", "1860", "1900", "1910", "1920", "1930", "1940", "1950", "1965"), "05", ifelse(iotable$BOC_2010_OCC_CODE %in% c("2000", "2010", "2015", "2016", "2025", "2040", "2050", "2060"), "06", ifelse(iotable$BOC_2010_OCC_CODE %in% c("2100", "2105", "2110", "2145", "2160"), "07", ifelse(iotable$BOC_2010_OCC_CODE %in% c("2200", "2300", "2310", "2320", "2330", "2340", "2400", "2430", "2440", "2540", "2550"), "08", ifelse(iotable$BOC_2010_OCC_CODE %in% c("2600", "2630", "2700", "2710", "2720", "2740", "2750", "2760", "2800", "2810", "2825", "2830", "2840", "2850", "2860", "2900", "2910", "2920", "2960"), "09", ifelse(iotable$BOC_2010_OCC_CODE %in% c("3000", "3010", "3030", "3040", "3050", "3060", "3110", "3120", "3130", "3140", "3150", "3160", "3200", "3210", "3220", "3230", "3235", "3245", "3250", "3255", "3256", "3257", "3258", "3260", "3300", "3310", "3320", "3400", "3420", "3500", "3510", "3520", "3535", "3540"), "10", ifelse(iotable$BOC_2010_OCC_CODE %in% c("3600", "3610", "3620", "3630", "3640", "3645", "3646", "3647", "3648", "3649", "3655"), "11", ifelse(iotable$BOC_2010_OCC_CODE %in% c("3700", "3710", "3720", "3730", "3740", "3750", "3800", "3820", "3830", "3840", "3850", "3860", "3900", "3910", "3930", "3940", "3945", "3955"), "12", ifelse(iotable$BOC_2010_OCC_CODE %in% c("4000", "4010", "4020", "4030", "4040", "4050", "4060", "4110", "4120", "4130", "4140", "4150", "4160"), "13", ifelse(iotable$BOC_2010_OCC_CODE %in% c("4200", "4210", "4220", "4230", "4240", "4250"), "14", ifelse(iotable$BOC_2010_OCC_CODE %in% c("4300", "4320", "4340", "4350", "4400", "4410", "4420", "4430", "4460", "4465", "4500", "4510", "4520", "4530", "4540", "4600", "4610", "4620", "4640", "4650"), "15", ifelse(iotable$BOC_2010_OCC_CODE %in% c("4700", "4710", "4720", "4740", "4750", "4760", "4800", "4810", "4820", "4830", "4840", "4850", "4900", "4920", "4930", "4940", "4950", "4965"), "16", ifelse(iotable$BOC_2010_OCC_CODE %in% c("5000", "5010", "5020", "5030", "5100", "5110", "5120", "5130", "5140", "5150", "5160", "5165", "5200", "5210", "5220", "5230", "5240", "5250", "5260", "5300", "5310", "5320", "5330", "5340", "5350", "5360", "5400", "5410", "5420", "5500", "5510", "5520", "5530", "5540", "5550", "5560", "5600", "5610", "5620", "5630", "5700", "5800", "5810", "5820", "5830", "5840", "5850", "5860", "5900", "5910", "5920", "5940"), "17", ifelse(iotable$BOC_2010_OCC_CODE %in% c("6005", "6010", "6020", "6040", "6050", "6100", "6110", "6120", "6130"), "18", ifelse(iotable$BOC_2010_OCC_CODE %in% c("6200", "6210", "6220", "6230", "6240", "6250", "6260", "6300", "6310", "6320", "6330", "6355", "6360", "6400", "6420", "6430", "6440", "6460", "6500", "6515", "6520", "6530", "6540", "6600", "6660", "6700", "6710", "6720", "6730", "6740", "6750", "6765", "6800", "6820", "6830", "6840", "6910", "6920", "6930", "6940"), "19", ifelse(iotable$BOC_2010_OCC_CODE %in% c("7000", "7010", "7020", "7030", "7040", "7050", "7100", "7110", "7120", "7130", "7140", "7150", "7160", "7200", "7210", "7220", "7240", "7260", "7300", "7315", "7320", "7330", "7340", "7350", "7360", "7410", "7420", "7430", "7440", "7510", "7520", "7540", "7550", "7560", "7600", "7610", "7630"), "20", ifelse(iotable$BOC_2010_OCC_CODE %in% c("7700", "7710", "7720", "7730", "7740", "7750", "7800", "7810", "7830", "7840", "7850", "7855", "7900", "7920", "7930", "7940", "7950", "7960", "8000", "8010", "8020", "8030", "8040", "8060", "8100", "8120", "8130", "8140", "8150", "8160", "8200", "8210", "8220", "8250", "8255", "8256", "8300", "8310", "8320", "8330", "8340", "8350", "8360", "8400", "8410", "8420", "8430", "8440", "8450", "8460", "8500", "8510", "8520", "8530", "8540", "8550", "8600", "8610", "8620", "8630", "8640", "8650", "8710", "8720", "8730", "8740", "8750", "8760", "8800", "8810", "8830", "8840", "8850", "8860", "8900", "8910", "8920", "8930", "8940", "8950", "8965"), "21", ifelse(iotable$BOC_2010_OCC_CODE %in% c("9000", "9030", "9040", "9050", "9110", "9120", "9130", "9140", "9150", "9200", "9230", "9240", "9260", "9300", "9310", "9330", "9340", "9350", "9360", "9410", "9415", "9420", "9500", "9510", "9520", "9560", "9600", "9610", "9620", "9630", "9640", "9650", "9720", "9730", "9740", "9750"), "22", ifelse(iotable$BOC_2010_OCC_CODE %in% c("9830", "9840", "9850"), "24",# NIOSH NCHS Military code ifelse(iotable$BOC_2010_OCC_CODE %in% c("9020", "9070", "9060", "9100", "9900"), "25", ifelse(iotable$BOC_2010_OCC_CODE %in% c("9010"), "26", NA))))))))))))))))))))))))) #------------------------------------------------------------------------------------------------------------------------- #For Census codes, swtich NIOSH NCHS military with: # ifelse(iotable$BOC_2010_OCC_CODE %in% c("9800", "9810", "9820", "9830", "9840"), "23", #and add: # ifelse(iotable$BOC_2010_OCC_CODE %in% c("9997"),"97", # ifelse(iotable$BOC_2010_OCC_CODE %in% c("9998"),"98", # ifelse(iotable$BOC_2010_OCC_CODE %in% c("9999"),"99", #Don't forget to add the appropriate parentheses to the end when adding code! #------------------------------------------------------------------------------------------------------------------------- #Create recode occupation titles iotable$occ.names <- with(iotable, ifelse(iotable$occ_simple == "01", "01 Management occupations", ifelse(iotable$occ_simple == "02", "02 Business and financial operations occupations", ifelse(iotable$occ_simple == "03", "03 Computer and mathematical occupations", ifelse(iotable$occ_simple == "04", "04 Architecture and engineering occupations", ifelse(iotable$occ_simple == "05", "05 Life, physical, and social science occupations", ifelse(iotable$occ_simple == "06", "06 Community and social services occupations", ifelse(iotable$occ_simple == "07", "07 Legal occupations", ifelse(iotable$occ_simple == "08", "08 Education, training, and library occupations", ifelse(iotable$occ_simple == "09", "09 Arts, design, entertainment, sports, and media occupations", ifelse(iotable$occ_simple == "10", "10 Healthcare practitioners and technical occupations", ifelse(iotable$occ_simple == "11", "11 Healthcare support occupations", ifelse(iotable$occ_simple == "12", "12 Protective service occupations", ifelse(iotable$occ_simple == "13", "13 Food preparation and serving related occupations", ifelse(iotable$occ_simple == "14", "14 Building and grounds cleaning and maintenance occupations", ifelse(iotable$occ_simple == "15", "15 Personal care and service occupations", ifelse(iotable$occ_simple == "16", "16 Sales and related occupations", ifelse(iotable$occ_simple == "17", "17 Office and administrative support occupations", ifelse(iotable$occ_simple == "18", "18 Farming, fishing, and forestry occupations", ifelse(iotable$occ_simple == "19", "19 Construction and extraction occupations", ifelse(iotable$occ_simple == "20", "20 Installation, maintenance, and repair occupations", ifelse(iotable$occ_simple == "21", "21 Production occupations", ifelse(iotable$occ_simple == "22", "22 Transportation and material moving occupations", ifelse(iotable$occ_simple == "24", "24 NIOSH NCHS Military", ifelse(iotable$occ_simple == "25", "25 NIOSH NCHS OTHER--MISC( Exc Housewife)", ifelse(iotable$occ_simple == "26", "26 NIOSH NCHS Other--Housewife", NA)))))))))))))))))))))))))) #------------------------------------------------------------------------------------------------------------------------ #For Census codes, swtich NIOSH military with: # ifelse(iotable$occ_simple == "23", "23 Census: Military Specific Occupations", #And add: # ifelse(iotable$occ_simple == "97", "97 Census: Refused, Classified", # ifelse(iotable$occ_simple == "98","98 Census: Not Ascertained", # ifelse(iotable$occ_simple == "99","99 Census: Do not know", #Don't forget to add the appropriate parentheses to the end when adding code! #---------------------------------------------------------------------------------------------------------------------- #*2007/2012 4-DIGIT NAICS-BASED CENSUS INDUSTRY CODES RECODED TO 2018 NHIS SIMPLE RECODES FOR INDUSTRY =IND_SIMPLE #INCLUDES CODES FOR 2007 SINCE THERE WAS A ONE-TO-ONE MATCH FOR CENSUS INDUSTRY CODES: SEE # HTTPS://WWW.CENSUS.GOV/TOPICS/EMPLOYMENT/INDUSTRY-OCCUPATION/GUIDANCE/CODE-LISTS.HTML #INCLUDES INDUSTRY CODE 2780 Metal forgings and stampings, WHICH WAS IN THE DETAILED RECODE BUT NOT THE SIMPLE iotable$ind_simple <-ifelse(iotable$BOC_2012_IND_CODE %in% c("0170", "0180", "0190", "0270", "0280", "0290"), "01", ifelse(iotable$BOC_2012_IND_CODE %in% c("0370", "0380", "0390", "0470", "0480", "0490"), "02", ifelse(iotable$BOC_2012_IND_CODE %in% c("0570", "0580", "0590", "0670", "0680", "0690"), "03", ifelse(iotable$BOC_2012_IND_CODE %in% c("0770"), "04", ifelse(iotable$BOC_2012_IND_CODE %in% c("1070", "1080", "1090", "1170", "1180", "1190", "1270", "1280", "1290", "1370", "1390", "1470", "1480", "1490", "1570", "1590", "1670", "1680", "1690", "1770", "1790", "1870", "1880", "1890", "1990", "2070", "2090", "2170", "2180", "2190", "2270", "2280", "2290", "2370", "2380", "2390", "2470", "2480", "2490", "2570", "2590", "2670", "2680", "2690", "2770", "2780", "2790", "2870", "2880", "2890", "2970", "2980", "2990", "3070", "3080", "3090", "3095", "3170", "3180", "3190", "3290", "3360", "3365", "3370", "3380", "3390", "3470", "3490", "3570", "3580", "3590", "3670", "3680", "3690", "3770", "3780", "3790", "3870", "3875", "3890", "3895", "3960", "3970", "3980", "3990"), "05", ifelse(iotable$BOC_2012_IND_CODE %in% c("4070", "4080", "4090", "4170", "4180", "4190", "4195", "4260", "4265", "4270", "4280", "4290", "4370", "4380", "4390", "4470", "4480", "4490", "4560", "4570", "4580", "4585", "4590"), "06", ifelse(iotable$BOC_2012_IND_CODE %in% c("4670", "4680", "4690", "4770", "4780", "4790", "4795", "4870", "4880", "4890", "4970", "4980", "4990", "5070", "5080", "5090", "5170", "5180", "5190", "5270", "5275", "5280", "5290", "5295", "5370", "5380", "5390", "5470", "5480", "5490", "5570", "5580", "5590", "5591", "5592", "5670", "5680", "5690", "5790"), "07", ifelse(iotable$BOC_2012_IND_CODE %in% c("6070", "6080", "6090", "6170", "6180", "6190", "6270", "6280", "6290", "6370", "6380", "6390"), "08", ifelse(iotable$BOC_2012_IND_CODE %in% c("6470", "6480", "6490", "6570", "6590", "6670", "6680", "6690", "6770", "6672", "6695", "6780"), "09", ifelse(iotable$BOC_2012_IND_CODE %in% c("6870", "6880", "6890", "6970", "6990"), "10", ifelse(iotable$BOC_2012_IND_CODE %in% c("7070", "7080", "7170", "7180", "7190"), "11", ifelse(iotable$BOC_2012_IND_CODE %in% c("7270", "7280", "7290", "7370", "7380", "7390", "7460", "7470", "7480", "7490"), "12", ifelse(iotable$BOC_2012_IND_CODE %in% c("7570"), "13", ifelse(iotable$BOC_2012_IND_CODE %in% c("7580", "7590", "7670", "7680", "7690", "7770", "7780", "7790"), "14", ifelse(iotable$BOC_2012_IND_CODE %in% c("7860", "7870", "7880", "7890"), "15", ifelse(iotable$BOC_2012_IND_CODE %in% c("7970", "7980", "7990", "8070", "8080", "8090", "8170", "8180", "8190", "8270", "8290", "8370", "8380", "8390", "8470"), "16", ifelse(iotable$BOC_2012_IND_CODE %in% c("8560", "8570", "8580", "8590"), "17", ifelse(iotable$BOC_2012_IND_CODE %in% c("8660", "8670", "8680", "8690"), "18", ifelse(iotable$BOC_2012_IND_CODE %in% c("8770", "8780", "8790", "8870", "8880", "8890", "8970", "8980", "8990", "9070", "9080", "9090", "9160", "9170", "9180", "9190", "9290"), "19", ifelse(iotable$BOC_2012_IND_CODE %in% c("9370", "9380", "9390", "9470", "9480", "9490", "9570", "9590"), "20", ifelse(iotable$BOC_2012_IND_CODE %in% c("9670", "9680", "9780", "9770", "9690", "9790"), "22", #NIOSH NCHS Military Code ifelse(iotable$BOC_2012_IND_CODE %in% c("9890", "9880", "9990"), "23", NA)))))))))))))))))))))) #------------------------------------------------------------------------------------------------------------------------ #For Census code, switch NIOSH Military code with: # ifelse(iotable$BOC_2012_IND_CODE %in% c("9670", "9680", "9690", "9770", "9780", "9790", "9870", "9890"), "21", #And add: # ifelse(iotable$BOC_2012_IND_CODE %in% c("9997"), "97", # ifelse(iotable$BOC_2012_IND_CODE %in% c("9998"),"98", # ifelse(iotable$BOC_2012_IND_CODE %in% c("9999"), "99", #Don't forget to add the appropriate parentheses to the end when adding code! #------------------------------------------------------------------------------------------------------------------------- #Create recode industry titles iotable$ind.names <- with(iotable, ifelse(iotable$ind_simple == "01", "01 Agriculture, Forestry, Fishing & Hunting ind.", ifelse(iotable$ind_simple == "02", "02 Mining ind.", ifelse(iotable$ind_simple == "03", "03 Utilities ind.", ifelse(iotable$ind_simple == "04", "04 Construction ind.", ifelse(iotable$ind_simple == "05", "05 Manufacturing ind.", ifelse(iotable$ind_simple == "06", "06 Wholesale Trade ind.", ifelse(iotable$ind_simple == "07", "07 Retail Trade ind.", ifelse(iotable$ind_simple == "08", "08 Transportation & Warehousing ind.", ifelse(iotable$ind_simple == "09", "09 information ind.", ifelse(iotable$ind_simple == "10", "10 Finance & insurance ind.", ifelse(iotable$ind_simple == "11", "11 Real Estate & Rental & Leasing ind.", ifelse(iotable$ind_simple == "12", "12 Professional, Scientific, & Technical Services ind.", ifelse(iotable$ind_simple == "13", "13 Management of Companies & Enterprises", ifelse(iotable$ind_simple == "14", "14 Admin. & Support & Waste mgmt & Remed. Svcs ind.", ifelse(iotable$ind_simple == "15", "15 Education Services ind.", ifelse(iotable$ind_simple == "16", "16 Healthcare & social Assistance ind.", ifelse(iotable$ind_simple == "17", "17 Arts, Entertainment, & Recreation ind.", ifelse(iotable$ind_simple == "18", "18 Accommodation & Food Services ind.", ifelse(iotable$ind_simple == "19", "19 Other Services (except Public Administration) ind.", ifelse(iotable$ind_simple == "20", "20 Public Administration ind.", ifelse(iotable$ind_simple == "22", "22 NiOSH NCHS Military", ifelse(iotable$ind_simple == "23", "23 NIOSH NCHS OTHER--MISC, MISSING", NA))))))))))))))))))))))) #------------------------------------------------------------------------------------------------------------------------ #For Census code, switch NIOSH NCHS Military code for: # ifelse(iotable$ind_simple == "21", "21 Census Military", #And add: # ifelse(iotable$ind_simple == "97", "97 CENSUS REFUSED CLASSIFIED", # ifelse(iotable$ind_simple == "98", "98 CENSUS NOT ASCERTAINED", # ifelse(iotable$ind_simple == "99", "99 CENSUS NOT ASCERTAINED", #Don't forget to add the appropriate parentheses to the end when adding code! #------------------------------------------------------------------------------------------------------------------------ #Output #Check for number of codes that were not categorized into simple categories sum(is.na(iotable$occ.names)) sum(is.na(iotable$ind.names)) #Table for count and percentage of Occupation and Industy freq(iotable$occ.names, cumul=FALSE, weights= NA, display.type = FALSE, report.nas = FALSE) freq(iotable$ind.names, cumul=FALSE, weights= NA, display.type = FALSE, report.nas = FALSE)