Core Employment Variables, Current Round section

Core Employment Variables, Current Round section

SAS Code for Variable Creation

data two; set r14.current
CALL SYMPUT ('E100000 ','YEMP_100000_01 YEMP_100000_02 YEMP_100000_03 YEMP_100000_04 YEMP_100000_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100100 ','YEMP_100100_01 YEMP_100100_02 YEMP_100100_03 YEMP_100100_04 YEMP_100100_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10020502 ','YEMP_100205_01_02 YEMP_100205_02_02 YEMP_100205_03_02 YEMP_100205_04_02 YEMP_100205_05_02 E06 E07 E08 E09 ');
CALL SYMPUT ('E10020503 ','YEMP_100205_01_03 YEMP_100205_02_03 YEMP_100205_03_03 E04 E05 E06 YEMP_100205_07_03 E08 E09 ');
CALL SYMPUT ('E10020504 ','YEMP_100205_01_04 YEMP_100205_02_04 YEMP_100205_03_04 YEMP_100205_04_04 YEMP_100205_05_04 E06 E07 E08 E09 ');
CALL SYMPUT ('E10020505 ','YEMP_100205_01_05 YEMP_100205_02_05 YEMP_100205_03_05 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10020506 ','YEMP_100205_01_06 YEMP_100205_02_06 YEMP_100205_03_06 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAA02 ','YEMP_100214AAA_01_02 YEMP_100214AAA_02_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAA03 ','YEMP_100214AAA_01_03 YEMP_100214AAA_02_03 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAA04 ','YEMP_100214AAA_01_04 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAA05 ','YEMP_100214AAA_01_05 YEMP_100214AAA_02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAA06 ','YEMP_100214AAA_01_06 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAB02 ','YEMP_100214AAB_01_02 YEMP_100214AAB_02_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAB03 ','YEMP_100214AAB_01_03 YEMP_100214AAB_02_03 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAB04 ','YEMP_100214AAB_01_04 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAB05 ','YEMP_100214AAB_01_05 YEMP_100214AAB_02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214AAB06 ','YEMP_100214AAB_01_06 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214B02 ','YEMP_100214B_01_02 YEMP_100214B_02_02 YEMP_100214B_03_02 YEMP_100214B_04_02 YEMP_100214B_05_02 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214B03 ','YEMP_100214B_01_03 YEMP_100214B_02_03 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214B04 ','YEMP_100214B_01_04 YEMP_100214B_02_04 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E100214B05 ','YEMP_100214B_01_05 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10021402 ','YEMP_100214_01_02 YEMP_100214_02_02 YEMP_100214_03_02 YEMP_100214_04_02 YEMP_100214_05_02 E06 E07 E08 E09 ');
CALL SYMPUT ('E10021403 ','YEMP_100214_01_03 YEMP_100214_02_03 YEMP_100214_03_03 E04 E05 E06 YEMP_100214_07_03 E08 E09 ');
CALL SYMPUT ('E10021404 ','YEMP_100214_01_04 YEMP_100214_02_04 YEMP_100214_03_04 YEMP_100214_04_04 YEMP_100214_05_04 E06 E07 E08 E09 ');
CALL SYMPUT ('E10021405 ','YEMP_100214_01_05 YEMP_100214_02_05 YEMP_100214_03_05 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10021406 ','YEMP_100214_01_06 YEMP_100214_02_06 YEMP_100214_03_06 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E101500 ','YEMP_101500_01 YEMP_101500_02 YEMP_101500_03 YEMP_101500_04 YEMP_101500_05 YEMP_101500_06 YEMP_101500_07 YEMP_101500_08 YEMP_101500_09 ');

CALL SYMPUT ('E10220001D ','YEMP_102200_01_01_D YEMP_102200_02_01_D YEMP_102200_03_01_D YEMP_102200_04_01_D E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10220001M ','YEMP_102200_01_01_M YEMP_102200_02_01_M YEMP_102200_03_01_M YEMP_102200_04_01_M E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10220001Y ','YEMP_102200_01_01_Y YEMP_102200_02_01_Y YEMP_102200_03_01_Y YEMP_102200_04_01_Y E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240002D ','YEMP_102400_01_02_D YEMP_102400_02_02_D YEMP_102400_03_02_D YEMP_102400_04_02_D E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240002M ','YEMP_102400_01_02_M YEMP_102400_02_02_M YEMP_102400_03_02_M YEMP_102400_04_02_M E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240002Y ','YEMP_102400_01_02_Y YEMP_102400_02_02_Y YEMP_102400_03_02_Y YEMP_102400_04_02_Y E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240003D ','YEMP_102400_01_03_D YEMP_102400_02_03_D YEMP_102400_03_03_D E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240003M ','YEMP_102400_01_03_M YEMP_102400_02_03_M YEMP_102400_03_03_M E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240003Y ','YEMP_102400_01_03_Y YEMP_102400_02_03_Y YEMP_102400_03_03_Y E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240004D ','YEMP_102400_01_04_D YEMP_102400_02_04_D YEMP_102400_03_04_D E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240004M ','YEMP_102400_01_04_M YEMP_102400_02_04_M YEMP_102400_03_04_M E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240004Y ','YEMP_102400_01_04_Y YEMP_102400_02_04_Y YEMP_102400_03_04_Y E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240005D ','YEMP_102400_01_05_D YEMP_102400_02_05_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240005M ','YEMP_102400_01_05_M YEMP_102400_02_05_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240005Y ','YEMP_102400_01_05_Y YEMP_102400_02_05_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240006D ','YEMP_102400_01_06_D YEMP_102400_02_06_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240006M ','YEMP_102400_01_06_M YEMP_102400_02_06_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240006Y ','YEMP_102400_01_06_Y YEMP_102400_02_06_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240007D ','YEMP_102400_01_07_D YEMP_102400_02_07_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240007M ','YEMP_102400_01_07_M YEMP_102400_02_07_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240007Y ','YEMP_102400_01_07_Y YEMP_102400_02_07_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240008D ','YEMP_102400_01_08_D YEMP_102400_02_08_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240008M ','YEMP_102400_01_08_M YEMP_102400_02_08_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240008Y ','YEMP_102400_01_08_Y YEMP_102400_02_08_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240009D ','YEMP_102400_01_09_D YEMP_102400_02_09_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240009M ','YEMP_102400_01_09_M YEMP_102400_02_09_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240009Y ','YEMP_102400_01_09_Y YEMP_102400_02_09_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240010D ','YEMP_102400_01_10_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240010M ','YEMP_102400_01_10_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240010Y ','YEMP_102400_01_10_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240011D ','YEMP_102400_01_11_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240011M ','YEMP_102400_01_11_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240011Y ','YEMP_102400_01_11_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240012D ','YEMP_102400_01_12_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240012M ','YEMP_102400_01_12_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240012Y ','YEMP_102400_01_12_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240013D ','YEMP_102400_01_13_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240013M ','YEMP_102400_01_13_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10240013Y ','YEMP_102400_01_13_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270001D ','YEMP_102700_01_01_D YEMP_102700_02_01_D YEMP_102700_03_01_D YEMP_102700_04_01_D E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270001M ','YEMP_102700_01_01_M YEMP_102700_02_01_M YEMP_102700_03_01_M YEMP_102700_04_01_M E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270001Y ','YEMP_102700_01_01_Y YEMP_102700_02_01_Y YEMP_102700_03_01_Y YEMP_102700_04_01_Y E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270002D ','YEMP_102700_01_02_D YEMP_102700_02_02_D YEMP_102700_03_02_D YEMP_102700_04_02_D E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270002M ','YEMP_102700_01_02_M YEMP_102700_02_02_M YEMP_102700_03_02_M YEMP_102700_04_02_M E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270002Y ','YEMP_102700_01_02_Y YEMP_102700_02_02_Y YEMP_102700_03_02_Y YEMP_102700_04_02_Y E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270003D ','YEMP_102700_01_03_D YEMP_102700_02_03_D YEMP_102700_03_03_D E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270003M ','YEMP_102700_01_03_M YEMP_102700_02_03_M YEMP_102700_03_03_M E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270003Y ','YEMP_102700_01_03_Y YEMP_102700_02_03_Y YEMP_102700_03_03_Y E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270004D ','YEMP_102700_01_04_D YEMP_102700_02_04_D YEMP_102700_03_04_D E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270004M ','YEMP_102700_01_04_M YEMP_102700_02_04_M YEMP_102700_03_04_M E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270004Y ','YEMP_102700_01_04_Y YEMP_102700_02_04_Y YEMP_102700_03_04_Y E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270005D ','YEMP_102700_01_05_D YEMP_102700_02_05_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270005M ','YEMP_102700_01_05_M YEMP_102700_02_05_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270005Y ','YEMP_102700_01_05_Y YEMP_102700_02_05_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270006D ','YEMP_102700_01_06_D YEMP_102700_02_06_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270006M ','YEMP_102700_01_06_M YEMP_102700_02_06_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270006Y ','YEMP_102700_01_06_Y YEMP_102700_02_06_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270007D ','YEMP_102700_01_07_D YEMP_102700_02_07_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270007M ','YEMP_102700_01_07_M YEMP_102700_02_07_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270007Y ','YEMP_102700_01_07_Y YEMP_102700_02_07_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270008D ','YEMP_102700_01_08_D YEMP_102700_02_08_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270008M ','YEMP_102700_01_08_M YEMP_102700_02_08_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270008Y ','YEMP_102700_01_08_Y YEMP_102700_02_08_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270009D ','YEMP_102700_01_09_D YEMP_102700_02_09_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270009M ','YEMP_102700_01_09_M YEMP_102700_02_09_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270009Y ','YEMP_102700_01_09_Y YEMP_102700_02_09_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270010D ','YEMP_102700_01_10_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270010M ','YEMP_102700_01_10_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270010Y ','YEMP_102700_01_10_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270011D ','YEMP_102700_01_11_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270011M ','YEMP_102700_01_11_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270011Y ','YEMP_102700_01_11_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270012D ','YEMP_102700_01_12_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270012M ','YEMP_102700_01_12_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270012Y ','YEMP_102700_01_12_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270013D ','YEMP_102700_01_13_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270013M ','YEMP_102700_01_13_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10270013Y ','YEMP_102700_01_13_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E103200 ','YEMP_103200_01 YEMP_103200_02 YEMP_103200_03 YEMP_103200_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370001 ','YEMP_103700_01_01 YEMP_103700_02_01 YEMP_103700_03_01 YEMP_103700_04_01 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370002 ','YEMP_103700_01_02 YEMP_103700_02_02 YEMP_103700_03_02 YEMP_103700_04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370003 ','YEMP_103700_01_03 YEMP_103700_02_03 YEMP_103700_03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370004 ','YEMP_103700_01_04 YEMP_103700_02_04 YEMP_103700_03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370005 ','YEMP_103700_01_05 YEMP_103700_02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370006 ','YEMP_103700_01_06 YEMP_103700_02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370007 ','YEMP_103700_01_07 YEMP_103700_02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370008 ','YEMP_103700_01_08 YEMP_103700_02_08 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370009 ','YEMP_103700_01_09 YEMP_103700_02_09 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370010 ','YEMP_103700_01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370011 ','YEMP_103700_01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370012 ','YEMP_103700_01_12 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10370013 ','YEMP_103700_01_13 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10540001 ','YEMP_105400_01_01 YEMP_105400_02_01 YEMP_105400_03_01 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10540002 ','YEMP_105400_01_02 YEMP_105400_02_02 E03 YEMP_105400_04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10540003 ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E105902 ','YEMP_105902_01 YEMP_105902_02 YEMP_105902_03 YEMP_105902_04 YEMP_105902_05 YEMP_105902_06 E07 E08 E09 ');
CALL SYMPUT ('E10591201D ','YEMP_105912_01_01_D YEMP_105912_02_01_D YEMP_105912_03_01_D E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591201M ','YEMP_105912_01_01_M YEMP_105912_02_01_M YEMP_105912_03_01_M E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591201Y ','YEMP_105912_01_01_Y YEMP_105912_02_01_Y YEMP_105912_03_01_Y E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591402D ','YEMP_105914_01_02_D YEMP_105914_02_02_D YEMP_105914_03_02_D E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591402M ','YEMP_105914_01_02_M YEMP_105914_02_02_M YEMP_105914_03_02_M E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591402Y ','YEMP_105914_01_02_Y YEMP_105914_02_02_Y YEMP_105914_03_02_Y E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591403D ','YEMP_105914_01_03_D YEMP_105914_02_03_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591403M ','YEMP_105914_01_03_M YEMP_105914_02_03_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591403Y ','YEMP_105914_01_03_Y YEMP_105914_02_03_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591404D ','YEMP_105914_01_04_D YEMP_105914_02_04_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591404M ','YEMP_105914_01_04_M YEMP_105914_02_04_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591404Y ','YEMP_105914_01_04_Y YEMP_105914_02_04_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591405D ','YEMP_105914_01_05_D YEMP_105914_02_05_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591405M ','YEMP_105914_01_05_M YEMP_105914_02_05_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591405Y ','YEMP_105914_01_05_Y YEMP_105914_02_05_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591406D ','YEMP_105914_01_06_D YEMP_105914_02_06_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591406M ','YEMP_105914_01_06_M YEMP_105914_02_06_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591406Y ','YEMP_105914_01_06_Y YEMP_105914_02_06_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591407D ','YEMP_105914_01_07_D YEMP_105914_02_07_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591407M ','YEMP_105914_01_07_M YEMP_105914_02_07_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591407Y ','YEMP_105914_01_07_Y YEMP_105914_02_07_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591408D ','YEMP_105914_01_08_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591408M ','YEMP_105914_01_08_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591408Y ','YEMP_105914_01_08_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591409D ','YEMP_105914_01_09_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591409M ','YEMP_105914_01_09_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591409Y ','YEMP_105914_01_09_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591410D ','YEMP_105914_01_10_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591410M ','YEMP_105914_01_10_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591410Y ','YEMP_105914_01_10_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591411D ','YEMP_105914_01_11_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591411M ','YEMP_105914_01_11_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591411Y ','YEMP_105914_01_11_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591601D ','YEMP_105916_01_01_D YEMP_105916_02_01_D YEMP_105916_03_01_D E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591601M ','YEMP_105916_01_01_M YEMP_105916_02_01_M YEMP_105916_03_01_M E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591601Y ','YEMP_105916_01_01_Y YEMP_105916_02_01_Y YEMP_105916_03_01_Y E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591602D ','YEMP_105916_01_02_D YEMP_105916_02_02_D YEMP_105916_03_02_D E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591602M ','YEMP_105916_01_02_M YEMP_105916_02_02_M YEMP_105916_03_02_M E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591602Y ','YEMP_105916_01_02_Y YEMP_105916_02_02_Y YEMP_105916_03_02_Y E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591603D ','YEMP_105916_01_03_D YEMP_105916_02_03_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591603M ','YEMP_105916_01_03_M YEMP_105916_02_03_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591603Y ','YEMP_105916_01_03_Y YEMP_105916_02_03_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591604D ','YEMP_105916_01_04_D YEMP_105916_02_04_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591604M ','YEMP_105916_01_04_M YEMP_105916_02_04_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591604Y ','YEMP_105916_01_04_Y YEMP_105916_02_04_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591605D ','YEMP_105916_01_05_D YEMP_105916_02_05_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591605M ','YEMP_105916_01_05_M YEMP_105916_02_05_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591605Y ','YEMP_105916_01_05_Y YEMP_105916_02_05_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591606D ','YEMP_105916_01_06_D YEMP_105916_02_06_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591606M ','YEMP_105916_01_06_M YEMP_105916_02_06_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591606Y ','YEMP_105916_01_06_Y YEMP_105916_02_06_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591607D ','YEMP_105916_01_07_D YEMP_105916_02_07_D E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591607M ','YEMP_105916_01_07_M YEMP_105916_02_07_M E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591607Y ','YEMP_105916_01_07_Y YEMP_105916_02_07_Y E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591608D ','YEMP_105916_01_08_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591608M ','YEMP_105916_01_08_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591608Y ','YEMP_105916_01_08_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591609D ','YEMP_105916_01_09_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591609M ','YEMP_105916_01_09_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591609Y ','YEMP_105916_01_09_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591610D ','YEMP_105916_01_10_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591610M ','YEMP_105916_01_10_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591610Y ','YEMP_105916_01_10_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591611D ','YEMP_105916_01_11_D E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591611M ','YEMP_105916_01_11_M E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591611Y ','YEMP_105916_01_11_Y E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E105920 ','YEMP_105920_01 YEMP_105920_02 YEMP_105920_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593801 ','YEMP_105938_01_01 YEMP_105938_02_01 YEMP_105938_03_01 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593802 ','YEMP_105938_01_02 YEMP_105938_02_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593803 ','YEMP_105938_01_03 YEMP_105938_02_03 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593804 ','YEMP_105938_01_04 YEMP_105938_02_04 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593805 ','YEMP_105938_01_05 YEMP_105938_02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593806 ','YEMP_105938_01_06 YEMP_105938_02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593807 ','YEMP_105938_01_07 YEMP_105938_02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593808 ','YEMP_105938_01_08 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593809 ','YEMP_105938_01_09 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593810 ','YEMP_105938_01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10593811 ','YEMP_105938_01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10595001 ','YEMP_105950_01_01 E02 YEMP_105950_03_01 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10595002 ','YEMP_105950_01_02 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10595003 ','YEMP_105950_01_03 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10595004 ','YEMP_105950_01_04 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10595010 ','YEMP_105950_01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E119000 ','YEMP_119000_01 YEMP_119000_02 YEMP_119000_03 YEMP_119000_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E119200 ','YEMP_119200_01 YEMP_119200_02 YEMP_119200_03 YEMP_119200_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E119300 ','YEMP_119300_01 YEMP_119300_02 YEMP_119300_03 YEMP_119300_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E19400 ','YEMP_19400_01 YEMP_19400_02 YEMP_19400_03 YEMP_19400_04 YEMP_19400_05 YEMP_19400_06 YEMP_19400_07 YEMP_19400_08 E09 ');
CALL SYMPUT ('E212001 ','YEMP_21200_01_1 YEMP_21200_02_1 YEMP_21200_03_1 YEMP_21200_04_1 YEMP_21200_05_1 YEMP_21200_06_1 E07 YEMP_21200_08_1 E09 ');
CALL SYMPUT ('E212002 ','YEMP_21200_01_2 YEMP_21200_02_2 YEMP_21200_03_2 YEMP_21200_04_2 YEMP_21200_05_2 YEMP_21200_06_2 E07 YEMP_21200_08_2 E09 ');
CALL SYMPUT ('E212003 ','YEMP_21200_01_3 YEMP_21200_02_3 YEMP_21200_03_3 YEMP_21200_04_3 YEMP_21200_05_3 YEMP_21200_06_3 E07 YEMP_21200_08_3 E09 ');
CALL SYMPUT ('E212004 ','YEMP_21200_01_4 YEMP_21200_02_4 YEMP_21200_03_4 YEMP_21200_04_4 YEMP_21200_05_4 YEMP_21200_06_4 E07 YEMP_21200_08_4 E09 ');
CALL SYMPUT ('E212005 ','YEMP_21200_01_5 YEMP_21200_02_5 YEMP_21200_03_5 YEMP_21200_04_5 YEMP_21200_05_5 YEMP_21200_06_5 E07 YEMP_21200_08_5 E09 ');
CALL SYMPUT ('E212006 ','YEMP_21200_01_6 YEMP_21200_02_6 YEMP_21200_03_6 YEMP_21200_04_6 YEMP_21200_05_6 YEMP_21200_06_6 E07 YEMP_21200_08_6 E09 ');
CALL SYMPUT ('E2160002 ','YEMP_21600_01_02 YEMP_21600_02_02 YEMP_21600_03_02 YEMP_21600_04_02 YEMP_21600_05_02 E06 E07 E08 E09 ');
CALL SYMPUT ('E2160003 ','YEMP_21600_01_03 YEMP_21600_02_03 YEMP_21600_03_03 E04 YEMP_21600_05_03 E06 E07 E08 E09 ');
CALL SYMPUT ('E2160004 ','YEMP_21600_01_04 YEMP_21600_02_04 YEMP_21600_03_04 YEMP_21600_04_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2160005 ','YEMP_21600_01_05 YEMP_21600_02_05 YEMP_21600_03_05 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2160006 ','YEMP_21600_01_06 YEMP_21600_02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2250002 ','YEMP_22500_01_02 YEMP_22500_02_02 YEMP_22500_03_02 YEMP_22500_04_02 YEMP_22500_05_02 E06 E07 E08 E09 ');
CALL SYMPUT ('E2250003 ','YEMP_22500_01_03 YEMP_22500_02_03 YEMP_22500_03_03 E04 YEMP_22500_05_03 E06 E07 E08 E09 ');
CALL SYMPUT ('E2250004 ','YEMP_22500_01_04 YEMP_22500_02_04 YEMP_22500_03_04 YEMP_22500_04_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2250005 ','YEMP_22500_01_05 YEMP_22500_02_05 YEMP_22500_03_05 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2250006 ','YEMP_22500_01_06 YEMP_22500_02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253002 ','YEMP_22530_01_02 YEMP_22530_02_02 YEMP_22530_03_02 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253003 ','YEMP_22530_01_03 YEMP_22530_02_03 YEMP_22530_03_03 E04 YEMP_22530_05_03 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253004 ','YEMP_22530_01_04 YEMP_22530_02_04 YEMP_22530_03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253005 ','YEMP_22530_01_05 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253006 ','YEMP_22530_01_06 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253502 ','YEMP_22535_01_02 YEMP_22535_02_02 YEMP_22535_03_02 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253503 ','YEMP_22535_01_03 YEMP_22535_02_03 YEMP_22535_03_03 E04 YEMP_22535_05_03 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253504 ','YEMP_22535_01_04 YEMP_22535_02_04 YEMP_22535_03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253505 ','YEMP_22535_01_05 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2253506 ','YEMP_22535_01_06 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2255002 ','YEMP_22550_01_02 YEMP_22550_02_02 YEMP_22550_03_02 YEMP_22550_04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2255003 ','YEMP_22550_01_03 YEMP_22550_02_03 YEMP_22550_03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2255004 ','YEMP_22550_01_04 E02 E03 YEMP_22550_04_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2255005 ','YEMP_22550_01_05 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E2255006 ','YEMP_22550_01_06 YEMP_22550_02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E22900 ','YEMP_22900_01 YEMP_22900_02 YEMP_22900_03 YEMP_22900_04 YEMP_22900_05 YEMP_22900_06 E07 YEMP_22900_08 E09 ');
CALL SYMPUT ('E23000 ','YEMP_23000_01 YEMP_23000_02 YEMP_23000_03 YEMP_23000_04 YEMP_23000_05 YEMP_23000_06 E07 E08 E09 ');
CALL SYMPUT ('E23200 ','YEMP_23200_01 YEMP_23200_02 E03 YEMP_23200_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E23901 ','YEMP_23901_01 YEMP_23901_02 YEMP_23901_03 YEMP_23901_04 YEMP_23901_05 YEMP_23901_06 E07 YEMP_23901_08 E09 ');
CALL SYMPUT ('E24501 ','YEMP_24501_01 YEMP_24501_02 YEMP_24501_03 YEMP_24501_04 YEMP_24501_05 YEMP_24501_06 E07 YEMP_24501_08 E09 ');
CALL SYMPUT ('E24502 ','YEMP_24502_01 YEMP_24502_02 YEMP_24502_03 YEMP_24502_04 YEMP_24502_05 YEMP_24502_06 E07 YEMP_24502_08 E09 ');
CALL SYMPUT ('E24514 ','YEMP_24514_01 YEMP_24514_02 YEMP_24514_03 YEMP_24514_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E24514B ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E33400 ','YEMP_33400_01 YEMP_33400_02 YEMP_33400_03 YEMP_33400_04 YEMP_33400_05 E06 YEMP_33400_07 E08 E09 ');
CALL SYMPUT ('E33500 ','YEMP_33500_01 YEMP_33500_02 YEMP_33500_03 E04 YEMP_33500_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E33600 ','YEMP_33600_01 YEMP_33600_02 YEMP_33600_03 YEMP_33600_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34402AAB ','YEMP_34402AAB_01 YEMP_34402AAB_02 YEMP_34402AAB_03 YEMP_34402AAB_04 YEMP_34402AAB_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34402AAD ','YEMP_34402AAD_01 YEMP_34402AAD_02 YEMP_34402AAD_03 YEMP_34402AAD_04 YEMP_34402AAD_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34402AB ','YEMP_34402AB_01 YEMP_34402AB_02 YEMP_34402AB_03 YEMP_34402AB_04 YEMP_34402AB_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34402 ','YEMP_34402_01 YEMP_34402_02 YEMP_34402_03 YEMP_34402_04 YEMP_34402_05 E06 YEMP_34402_07 E08 E09 ');
CALL SYMPUT ('E34403 ','YEMP_34403_01 YEMP_34403_02 YEMP_34403_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34404 ','YEMP_34404_01 YEMP_34404_02 YEMP_34404_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34413C ','YEMP_34413C_01 YEMP_34413C_02 YEMP_34413C_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34413CC ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34413CD ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E34428 ','YEMP_34428_01 YEMP_34428_02 YEMP_34428_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E35600 ','YEMP_35600_01 YEMP_35600_02 YEMP_35600_03 E04 YEMP_35600_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E36100 ','YEMP_36100_01 YEMP_36100_02 YEMP_36100_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E36200 ','YEMP_36200_01 YEMP_36200_02 YEMP_36200_03 YEMP_36200_04 YEMP_36200_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E37701 ','YEMP_37701_01 YEMP_37701_02 YEMP_37701_03 YEMP_37701_04 YEMP_37701_05 YEMP_37701_06 YEMP_37701_07 YEMP_37701_08 E09 ');
CALL SYMPUT ('E37901B ','YEMP_37901B_01 YEMP_37901B_02 YEMP_37901B_03 YEMP_37901B_04 YEMP_37901B_05 YEMP_37901B_06 YEMP_37901B_07 YEMP_37901B_08 E09 ');
CALL SYMPUT ('E37904 ','YEMP_37904_01 YEMP_37904_02 YEMP_37904_03 YEMP_37904_04 YEMP_37904_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38000B ','YEMP_38000B_01 YEMP_38000B_02 YEMP_38000B_03 YEMP_38000B_04 YEMP_38000B_05 YEMP_38000B_06 YEMP_38000B_07 E08 E09 ');
CALL SYMPUT ('E38000F ','YEMP_38000F_01 YEMP_38000F_02 YEMP_38000F_03 YEMP_38000F_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38002 ','YEMP_38002_01 YEMP_38002_02 YEMP_38002_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38003 ','YEMP_38003_01 YEMP_38003_02 YEMP_38003_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38012 ','YEMP_38012_01 YEMP_38012_02 YEMP_38012_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38012B ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38013B ','YEMP_38013B_01 YEMP_38013B_02 YEMP_38013B_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38013 ','YEMP_38013_01 YEMP_38013_02 YEMP_38013_03 YEMP_38013_04 YEMP_38013_05 YEMP_38013_06 YEMP_38013_07 E08 E09 ');
CALL SYMPUT ('E38014 ','YEMP_38014_01 YEMP_38014_02 YEMP_38014_03 YEMP_38014_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38023 ','YEMP_38023_01 YEMP_38023_02 YEMP_38023_03 YEMP_38023_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38024B ','YEMP_38024B_01 YEMP_38024B_02 E03 YEMP_38024B_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38024C ','YEMP_38024C_01 YEMP_38024C_02 E03 YEMP_38024C_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38027 ','YEMP_38027_01 YEMP_38027_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38102 ','YEMP_38102_01 YEMP_38102_02 YEMP_38102_03 YEMP_38102_04 YEMP_38102_05 YEMP_38102_06 E07 E08 E09 ');
CALL SYMPUT ('E38103 ','YEMP_38103_01 YEMP_38103_02 YEMP_38103_03 YEMP_38103_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38105 ','YEMP_38105_01 YEMP_38105_02 YEMP_38105_03 YEMP_38105_04 YEMP_38105_05 YEMP_38105_06 E07 E08 E09 ');
CALL SYMPUT ('E38106 ','YEMP_38106_01 YEMP_38106_02 YEMP_38106_03 YEMP_38106_04 YEMP_38106_05 YEMP_38106_06 E07 YEMP_38106_08 E09 ');
CALL SYMPUT ('E38107 ','YEMP_38107_01 YEMP_38107_02 YEMP_38107_03 YEMP_38107_04 E05 YEMP_38107_06 E07 E08 E09 ');
CALL SYMPUT ('E38116 ','YEMP_38116_01 YEMP_38116_02 YEMP_38116_03 YEMP_38116_04 E05 YEMP_38116_06 E07 E08 E09 ');
CALL SYMPUT ('E38116B ','YEMP_38116B_01 E02 YEMP_38116B_03 E04 E05 E06 E07 E08 E09 ');

CALL SYMPUT ('E38201 ','YEMP_38201_01 YEMP_38201_02 YEMP_38201_03 YEMP_38201_04 E05 YEMP_38201_06 E07 E08 E09 ');
CALL SYMPUT ('E38202 ','YEMP_38202_01 YEMP_38202_02 YEMP_38202_03 YEMP_38202_04 E05 YEMP_38202_06 E07 E08 E09 ');
CALL SYMPUT ('E38211 ','YEMP_38211_01 YEMP_38211_02 YEMP_38211_03 YEMP_38211_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38329B ','YEMP_38329B_01 YEMP_38329B_02 YEMP_38329B_03 YEMP_38329B_04 YEMP_38329B_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38329D ','YEMP_38329D_01 YEMP_38329D_02 YEMP_38329D_03 YEMP_38329D_04 YEMP_38329D_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38329I ','YEMP_38329I_01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38329IB ','YEMP_38329IB_01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38329K ','YEMP_38329K_01 YEMP_38329K_02 E03 YEMP_38329K_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3840701 ','YEMP_38407_01_01 YEMP_38407_02_01 YEMP_38407_03_01 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3840702 ','YEMP_38407_01_02 YEMP_38407_02_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3840703 ','YEMP_38407_01_03 YEMP_38407_02_03 YEMP_38407_03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3840704 ','YEMP_38407_01_04 YEMP_38407_02_04 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3840705 ','YEMP_38407_01_05 YEMP_38407_02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416IB02 ','YEMP_38416IB_01_02 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416IB03 ','YEMP_38416IB_01_03 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416IB04 ','YEMP_38416IB_01_04 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416IB05 ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416ID02 ','YEMP_38416ID_01_02 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416ID03 ','YEMP_38416ID_01_03 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416ID04 ','YEMP_38416ID_01_04 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416ID05 ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416I02 ','YEMP_38416I_01_02 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416I03 ','YEMP_38416I_01_03 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416I04 ','YEMP_38416I_01_04 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416I05 ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416K01 ','YEMP_38416K_01_01 YEMP_38416K_02_01 YEMP_38416K_03_01 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416K02 ','YEMP_38416K_01_02 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416K03 ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E38416K05 ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3841601 ','YEMP_38416_01_01 YEMP_38416_02_01 YEMP_38416_03_01 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3841602 ','YEMP_38416_01_02 YEMP_38416_02_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3841603 ','YEMP_38416_01_03 YEMP_38416_02_03 YEMP_38416_03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3841604 ','YEMP_38416_01_04 YEMP_38416_02_04 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E3841605 ','YEMP_38416_01_05 YEMP_38416_02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E58201 ','YEMP_58201_01 YEMP_58201_02 YEMP_58201_03 YEMP_58201_04 YEMP_58201_05 YEMP_58201_06 YEMP_58201_07 E08 YEMP_58201_09 ');
CALL SYMPUT ('E58401 ','YEMP_58401_01 YEMP_58401_02 YEMP_58401_03 YEMP_58401_04 YEMP_58401_05 YEMP_58401_06 YEMP_58401_07 YEMP_58401_08 YEMP_58401_09 ');
CALL SYMPUT ('E59900 ','YEMP_59900_01 YEMP_59900_02 YEMP_59900_03 YEMP_59900_04 YEMP_59900_05 YEMP_59900_06 YEMP_59900_07 E08 YEMP_59900_09 ');
CALL SYMPUT ('E59901 ','YEMP_59901_01 YEMP_59901_02 YEMP_59901_03 YEMP_59901_04 YEMP_59901_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E83100 ','YEMP_83100_01 YEMP_83100_02 YEMP_83100_03 YEMP_83100_04 YEMP_83100_05 YEMP_83100_06 YEMP_83100_07 E08 YEMP_83100_09 ');
CALL SYMPUT ('E83300 ','YEMP_83300_01 YEMP_83300_02 YEMP_83300_03 YEMP_83300_04 YEMP_83300_05 YEMP_83300_06 YEMP_83300_07 E08 YEMP_83300_09 ');
CALL SYMPUT ('E86800 ','YEMP_86800_01 YEMP_86800_02 YEMP_86800_03 YEMP_86800_04 YEMP_86800_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E86900 ','YEMP_86900_01 YEMP_86900_02 YEMP_86900_03 YEMP_86900_04 YEMP_86900_05 YEMP_86900_06 E07 E08 YEMP_86900_09 ');
CALL SYMPUT ('E87100 ','YEMP_87100_01 YEMP_87100_02 YEMP_87100_03 YEMP_87100_04 YEMP_87100_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E88000 ','YEMP_88000_01 YEMP_88000_02 YEMP_88000_03 YEMP_88000_04 YEMP_88000_05 YEMP_88000_06 E07 E08 YEMP_88000_09 ');
CALL SYMPUT ('E88501 ','YEMP_88501_01 YEMP_88501_02 YEMP_88501_03 YEMP_88501_04 YEMP_88501_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E88502A ','YEMP_88502A_01 YEMP_88502A_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E88502 ','YEMP_88502_01 YEMP_88502_02 YEMP_88502_03 YEMP_88502_04 YEMP_88502_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E88512 ','YEMP_88512_01 YEMP_88512_02 YEMP_88512_03 YEMP_88512_04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E97300 ','YEMP_97300_01 YEMP_97300_02 YEMP_97300_03 YEMP_97300_04 YEMP_97300_05 YEMP_97300_06 E07 E08 E09 ');
CALL SYMPUT ('E97400 ','YEMP_97400_01 YEMP_97400_02 YEMP_97400_03 YEMP_97400_04 YEMP_97400_05 E06 YEMP_97400_07 E08 E09 ');
CALL SYMPUT ('E97500 ','YEMP_97500_01 YEMP_97500_02 YEMP_97500_03 YEMP_97500_04 YEMP_97500_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E98300 ','YEMP_98300_01 YEMP_98300_02 YEMP_98300_03 E04 E05 YEMP_98300_06 E07 E08 E09 ');
CALL SYMPUT ('E98402CAA ','YEMP_98402CAA_01 YEMP_98402CAA_02 YEMP_98402CAA_03 YEMP_98402CAA_04 YEMP_98402CAA_05 E06 YEMP_98402CAA_07 E08 E09 ');
CALL SYMPUT ('E98402CAB ','YEMP_98402CAB_01 YEMP_98402CAB_02 YEMP_98402CAB_03 YEMP_98402CAB_04 YEMP_98402CAB_05 E06 YEMP_98402CAB_07 E08 E09 ');
CALL SYMPUT ('E98402D ','YEMP_98402D_01 YEMP_98402D_02 YEMP_98402D_03 E04 YEMP_98402D_05 YEMP_98402D_06 E07 E08 E09 ');
CALL SYMPUT ('E98402 ','YEMP_98402_01 YEMP_98402_02 YEMP_98402_03 YEMP_98402_04 YEMP_98402_05 YEMP_98402_06 YEMP_98402_07 E08 E09 ');
CALL SYMPUT ('E98403 ','YEMP_98403_01 YEMP_98403_02 YEMP_98403_03 YEMP_98403_04 YEMP_98403_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E98404ABX ','YEMP_98404ABX_01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E98404A ','YEMP_98404A_01 YEMP_98404A_02 YEMP_98404A_03 YEMP_98404A_04 YEMP_98404A_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E98414AAA ','YEMP_98414AAA_01 YEMP_98414AAA_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E98414AAB ','YEMP_98414AAB_01 YEMP_98414AAB_02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E98414B ','YEMP_98414B_01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E98414 ','YEMP_98414_01 YEMP_98414_02 YEMP_98414_03 YEMP_98414_04 YEMP_98414_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E98429 ','YEMP_98429_01 YEMP_98429_02 YEMP_98429_03 YEMP_98429_04 YEMP_98429_05 E06 E07 E08 E09 ');
CALL SYMPUT ('E9899M ','YEMP_9899M_01 YEMP_9899M_02 YEMP_9899M_03 YEMP_9899M_04 YEMP_9899M_05 YEMP_9899M_06 YEMP_9899M_07 YEMP_9899M_08 E09 ');
CALL SYMPUT ('E99500 ','YEMP_99500_01 YEMP_99500_02 YEMP_99500_03 YEMP_99500_04 YEMP_99500_05 E06 E07 E08 E09 ');

CALL SYMPUT ('R0CUR ','YEMP_CURFLAG_01 YEMP_CURFLAG_02 YEMP_CURFLAG_03 YEMP_CURFLAG_04 YEMP_CURFLAG_05 YEMP_CURFLAG_06 YEMP_CURFLAG_07 YEMP_CURFLAG_08 YEMP_CURFLAG_09 ');
CALL SYMPUT ('R0MIL ','YEMP_MILFLAG_01 YEMP_MILFLAG_02 YEMP_MILFLAG_03 YEMP_MILFLAG_04 YEMP_MILFLAG_05 YEMP_MILFLAG_06 YEMP_MILFLAG_07 YEMP_MILFLAG_08 YEMP_MILFLAG_09 ');
CALL SYMPUT ('R0SEL ','YEMP_SELFEMP_01 YEMP_SELFEMP_02 YEMP_SELFEMP_03 YEMP_SELFEMP_04 YEMP_SELFEMP_05 YEMP_SELFEMP_06 YEMP_SELFEMP_07 YEMP_SELFEMP_08 YEMP_SELFEMP_09 ');
CALL SYMPUT ('R0STAD ','YEMP_STARTDATE_01_D YEMP_STARTDATE_02_D YEMP_STARTDATE_03_D YEMP_STARTDATE_04_D YEMP_STARTDATE_05_D YEMP_STARTDATE_06_D YEMP_STARTDATE_07_D YEMP_STARTDATE_08_D YEMP_STARTDATE_09_D ');
CALL SYMPUT ('R0STAM ','YEMP_STARTDATE_01_M YEMP_STARTDATE_02_M YEMP_STARTDATE_03_M YEMP_STARTDATE_04_M YEMP_STARTDATE_05_M YEMP_STARTDATE_06_M YEMP_STARTDATE_07_M YEMP_STARTDATE_08_M YEMP_STARTDATE_09_M ');
CALL SYMPUT ('R0STAY ','YEMP_STARTDATE_01_Y YEMP_STARTDATE_02_Y YEMP_STARTDATE_03_Y YEMP_STARTDATE_04_Y YEMP_STARTDATE_05_Y YEMP_STARTDATE_06_Y YEMP_STARTDATE_07_Y YEMP_STARTDATE_08_Y YEMP_STARTDATE_09_Y ');
CALL SYMPUT ('R0STOD ','YEMP_STOPDATE_01_D YEMP_STOPDATE_02_D YEMP_STOPDATE_03_D YEMP_STOPDATE_04_D YEMP_STOPDATE_05_D YEMP_STOPDATE_06_D YEMP_STOPDATE_07_D YEMP_STOPDATE_08_D YEMP_STOPDATE_09_D ');
CALL SYMPUT ('R0STOM ','YEMP_STOPDATE_01_M YEMP_STOPDATE_02_M YEMP_STOPDATE_03_M YEMP_STOPDATE_04_M YEMP_STOPDATE_05_M YEMP_STOPDATE_06_M YEMP_STOPDATE_07_M YEMP_STOPDATE_08_M YEMP_STOPDATE_09_M ');
CALL SYMPUT ('R0STOY ','YEMP_STOPDATE_01_Y YEMP_STOPDATE_02_Y YEMP_STOPDATE_03_Y YEMP_STOPDATE_04_Y YEMP_STOPDATE_05_Y YEMP_STOPDATE_06_Y YEMP_STOPDATE_07_Y YEMP_STOPDATE_08_Y YEMP_STOPDATE_09_Y ');
CALL SYMPUT ('R0UID ','YEMP_UID_01 YEMP_UID_02 YEMP_UID_03 YEMP_UID_04 YEMP_UID_05 YEMP_UID_06 YEMP_UID_07 YEMP_UID_08 YEMP_UID_09 ');

CALL SYMPUT ('E10591412Y ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591412M ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591412D ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591413Y ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591413M ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591413D ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591612Y ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591612M ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591612D ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591613Y ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591613M ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('E10591613D ','E01 E02 E03 E04 E05 E06 E07 E08 E09 ');

CALL SYMPUT ('STARD ','STARD01 STARD02 STARD03 STARD04 STARD05 STARD06 STARD07 STARD08 STARD09 ');
CALL SYMPUT ('STARM ','STARM01 STARM02 STARM03 STARM04 STARM05 STARM06 STARM07 STARM08 STARM09 ');
CALL SYMPUT ('STARY ','STARY01 STARY02 STARY03 STARY04 STARY05 STARY06 STARY07 STARY08 STARY09 ');
CALL SYMPUT ('STOPD ','STOPD01 STOPD02 STOPD03 STOPD04 STOPD05 STOPD06 STOPD07 STOPD08 STOPD09 ');
CALL SYMPUT ('STOPM ','STOPM01 STOPM02 STOPM03 STOPM04 STOPM05 STOPM06 STOPM07 STOPM08 STOPM09 ');
CALL SYMPUT ('STOPY ','STOPY01 STOPY02 STOPY03 STOPY04 STOPY05 STOPY06 STOPY07 STOPY08 STOPY09 ');
CALL SYMPUT ('STARW ','STARW01 STARW02 STARW03 STARW04 STARW05 STARW06 STARW07 STARW08 STARW09 ');
CALL SYMPUT ('STOPW ','STOPW01 STOPW02 STOPW03 STOPW04 STOPW05 STOPW06 STOPW07 STOPW08 STOPW09 ');
CALL SYMPUT ('SMOF ','SMOF01 SMOF02 SMOF03 SMOF04 SMOF05 SMOF06 SMOF07 SMOF08 SMOF09 ');
CALL SYMPUT ('EMOF ','EMOF01 EMOF02 EMOF03 EMOF04 EMOF05 EMOF06 EMOF07 EMOF08 EMOF09 ');

CALL SYMPUT ('BGFL_01 ','BGFL01_01 BGFL02_01 BGFL03_01 BGFL04_01 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_02 ','BGFL01_02 BGFL02_02 BGFL03_02 BGFL04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_03 ','BGFL01_03 BGFL02_03 BGFL03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_04 ','BGFL01_04 BGFL02_04 BGFL03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_05 ','BGFL01_05 BGFL02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_06 ','BGFL01_06 BGFL02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_07 ','BGFL01_07 BGFL02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_08 ','BGFL01_08 BGFL02_08 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_09 ','BGFL01_09 BGFL02_09 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_10 ','BGFL01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_11 ','BGFL01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_12 ','BGFL01_12 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGFL_13 ','BGFL01_13 E02 E03 E04 E05 E06 E07 E08 E09 ');

CALL SYMPUT ('EGFL_01 ','EGFL01_01 EGFL02_01 EGFL03_01 EGFL04_01 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_02 ','EGFL01_02 EGFL02_02 EGFL03_02 EGFL04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_03 ','EGFL01_03 EGFL02_03 EGFL03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_04 ','EGFL01_04 EGFL02_04 EGFL03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_05 ','EGFL01_05 EGFL02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_06 ','EGFL01_06 EGFL02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_07 ','EGFL01_07 EGFL02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_08 ','EGFL01_08 EGFL02_08 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_09 ','EGFL01_09 EGFL02_09 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_10 ','EGFL01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_11 ','EGFL01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_12 ','EGFL01_12 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGFL_13 ','EGFL01_13 E02 E03 E04 E05 E06 E07 E08 E09 ');

CALL SYMPUT ('BGAP_01 ','BGAP01_01 BGAP02_01 BGAP03_01 BGAP04_01 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_02 ','BGAP01_02 BGAP02_02 BGAP03_02 BGAP04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_03 ','BGAP01_03 BGAP02_03 BGAP03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_04 ','BGAP01_04 BGAP02_04 BGAP03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_05 ','BGAP01_05 BGAP02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_06 ','BGAP01_06 BGAP02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_07 ','BGAP01_07 BGAP02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_08 ','BGAP01_08 BGAP02_08 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_09 ','BGAP01_09 BGAP02_09 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_10 ','BGAP01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_11 ','BGAP01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_12 ','BGAP01_12 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('BGAP_13 ','BGAP01_13 E02 E03 E04 E05 E06 E07 E08 E09 ');

CALL SYMPUT ('EGAP_01 ','EGAP01_01 EGAP02_01 EGAP03_01 EGAP04_01 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_02 ','EGAP01_02 EGAP02_02 EGAP03_02 EGAP04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_03 ','EGAP01_03 EGAP02_03 EGAP03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_04 ','EGAP01_04 EGAP02_04 EGAP03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_05 ','EGAP01_05 EGAP02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_06 ','EGAP01_06 EGAP02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_07 ','EGAP01_07 EGAP02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_08 ','EGAP01_08 EGAP02_08 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_09 ','EGAP01_09 EGAP02_09 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_10 ','EGAP01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_11 ','EGAP01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_12 ','EGAP01_12 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('EGAP_13 ','EGAP01_13 E02 E03 E04 E05 E06 E07 E08 E09 ');

CALL SYMPUT ('_BGMDY_01 ','_BGMDY01_01 _BGMDY02_01 _BGMDY03_01 _BGMDY04_01 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_02 ','_BGMDY01_02 _BGMDY02_02 _BGMDY03_02 _BGMDY04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_03 ','_BGMDY01_03 _BGMDY02_03 _BGMDY03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_04 ','_BGMDY01_04 _BGMDY02_04 _BGMDY03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_05 ','_BGMDY01_05 _BGMDY02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_06 ','_BGMDY01_06 _BGMDY02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_07 ','_BGMDY01_07 _BGMDY02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_08 ','_BGMDY01_08 _BGMDY02_08 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_09 ','_BGMDY01_09 _BGMDY02_09 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_10 ','_BGMDY01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_11 ','_BGMDY01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_12 ','_BGMDY01_12 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_BGMDY_13 ','_BGMDY01_13 E02 E03 E04 E05 E06 E07 E08 E09 ');

CALL SYMPUT ('_EGMDY_01 ','_EGMDY01_01 _EGMDY02_01 _EGMDY03_01 _EGMDY04_01 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_02 ','_EGMDY01_02 _EGMDY02_02 _EGMDY03_02 _EGMDY04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_03 ','_EGMDY01_03 _EGMDY02_03 _EGMDY03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_04 ','_EGMDY01_04 _EGMDY02_04 _EGMDY03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_05 ','_EGMDY01_05 _EGMDY02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_06 ','_EGMDY01_06 _EGMDY02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_07 ','_EGMDY01_07 _EGMDY02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_08 ','_EGMDY01_08 _EGMDY02_08 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_09 ','_EGMDY01_09 _EGMDY02_09 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_10 ','_EGMDY01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_11 ','_EGMDY01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_12 ','_EGMDY01_12 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_EGMDY_13 ','_EGMDY01_13 E02 E03 E04 E05 E06 E07 E08 E09 ');

CALL SYMPUT ('_gdays_01 ','_gdays01_01 _gdays02_01 _gdays03_01 _gdays04_01 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_02 ','_gdays01_02 _gdays02_02 _gdays03_02 _gdays04_02 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_03 ','_gdays01_03 _gdays02_03 _gdays03_03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_04 ','_gdays01_04 _gdays02_04 _gdays03_04 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_05 ','_gdays01_05 _gdays02_05 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_06 ','_gdays01_06 _gdays02_06 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_07 ','_gdays01_07 _gdays02_07 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_08 ','_gdays01_08 _gdays02_08 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_09 ','_gdays01_09 _gdays02_09 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_10 ','_gdays01_10 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_11 ','_gdays01_11 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_12 ','_gdays01_12 E02 E03 E04 E05 E06 E07 E08 E09 ');
CALL SYMPUT ('_gdays_13 ','_gdays01_13 E02 E03 E04 E05 E06 E07 E08 E09 ');

data emp_bday (keep=pubid birthwk age14wk age18wk age20wk ag18jan birthyr);
set r14.prior;
  birthwk=CV_BIRTH_WK;  
  age14wk=CV_AGE14_WK;
  age18wk=CV_AGE18_WK;
  age20wk=CV_AGE20_WK;
  ag18jmdy=mdy(01,01,birthyr+18);
  begmdy=mdy(01,01,1980);
  ag18jan=intck('week',begmdy,ag18jmdy)+1;

proc means n mean min max data=emp_bday;
var pubid birthwk age14wk age18wk age20wk ag18jan birthyr;
title  'Round14';
title2 'Emp_bday';
run;

data emp_int;
merge two(keep=pubid CV_INTERVIEW_DATE_D CV_INTERVIEW_DATE_M CV_INTERVIEW_DATE_Y)
      r14.prior;
by pubid;
      
   r1int_d=CV_INTERVIEW_DATE_D_1997;    label r1int_d = "CV_INTERVIEW_DATE 1997";                       
   r1int_m=CV_INTERVIEW_DATE_M_1997;    label r1int_m = "CV_INTERVIEW_DATE 1997";                       
   r1int_y=CV_INTERVIEW_DATE_Y_1997;    label r1int_y = "CV_INTERVIEW_DATE 1997";  
   r2int_d=CV_INTERVIEW_DATE_D_1998;    label r2int_d = "CV_INTERVIEW_DATE 1998";            
   r2int_m=CV_INTERVIEW_DATE_M_1998;    label r2int_m = "CV_INTERVIEW_DATE 1998";            
   r2int_y=CV_INTERVIEW_DATE_Y_1998;    label r2int_y = "CV_INTERVIEW_DATE 1998";            
   r3int_d=CV_INTERVIEW_DATE_D_1999;    label r3int_d = "CV_INTERVIEW_DATE 1999";            
   r3int_m=CV_INTERVIEW_DATE_M_1999;    label r3int_m = "CV_INTERVIEW_DATE 1999";            
   r3int_y=CV_INTERVIEW_DATE_Y_1999;    label r3int_y = "CV_INTERVIEW_DATE 1999";            
   r4int_d=CV_INTERVIEW_DATE_D_2000;    label r4int_d = "CV_INTERVIEW_DATE 2000";
   r4int_m=CV_INTERVIEW_DATE_M_2000;    label r4int_m = "CV_INTERVIEW_DATE 2000";
   r4int_y=CV_INTERVIEW_DATE_Y_2000;    label r4int_y = "CV_INTERVIEW_DATE 2000";
   r5int_d=CV_INTERVIEW_DATE_D_2001;    label r5int_d = "CV_INTERVIEW_DATE 2001";
   r5int_m=CV_INTERVIEW_DATE_M_2001;    label r5int_m = "CV_INTERVIEW_DATE 2001";
   r5int_y=CV_INTERVIEW_DATE_Y_2001;    label r5int_y = "CV_INTERVIEW_DATE 2001";
   r6int_d=CV_INTERVIEW_DATE_D_2002;    label r6int_d = "CV_INTERVIEW_DATE 2002";
   r6int_m=CV_INTERVIEW_DATE_M_2002;    label r6int_m = "CV_INTERVIEW_DATE 2002";
   r6int_y=CV_INTERVIEW_DATE_Y_2002;    label r6int_y = "CV_INTERVIEW_DATE 2002";
   r7int_d=CV_INTERVIEW_DATE_D_2003;    label r7int_d = "CV_INTERVIEW_DATE 2003";      
   r7int_m=CV_INTERVIEW_DATE_M_2003;    label r7int_m = "CV_INTERVIEW_DATE 2003";      
   r7int_y=CV_INTERVIEW_DATE_Y_2003;    label r7int_y = "CV_INTERVIEW_DATE 2003";      
   r8int_d=CV_INTERVIEW_DATE_D_2004;    label r8int_d = "CV_INTERVIEW_DATE 2004";
   r8int_m=CV_INTERVIEW_DATE_M_2004;    label r8int_m = "CV_INTERVIEW_DATE 2004";
   r8int_y=CV_INTERVIEW_DATE_Y_2004;    label r8int_y = "CV_INTERVIEW_DATE 2004";
   r9int_d=CV_INTERVIEW_DATE_D_2005;    label r9int_d = "CV_INTERVIEW_DATE 2005";
   r9int_m=CV_INTERVIEW_DATE_M_2005;    label r9int_m = "CV_INTERVIEW_DATE 2005";
   r9int_y=CV_INTERVIEW_DATE_Y_2005;    label r9int_y = "CV_INTERVIEW_DATE 2005";  
   r10int_d=CV_INTERVIEW_DATE_D_2006;   label r10int_d = "CV_INTERVIEW_DATE 2006";
   r10int_m=CV_INTERVIEW_DATE_M_2006;   label r10int_m = "CV_INTERVIEW_DATE 2006";
   r10int_y=CV_INTERVIEW_DATE_Y_2006;   label r10int_y = "CV_INTERVIEW_DATE 2006";
   r11int_d=CV_INTERVIEW_DATE_D_2007;   label r11int_d = "CV_INTERVIEW_DATE 2007";
   r11int_m=CV_INTERVIEW_DATE_M_2007;   label r11int_m = "CV_INTERVIEW_DATE 2007";
   r11int_y=CV_INTERVIEW_DATE_Y_2007;   label r11int_y = "CV_INTERVIEW_DATE 2007";
   r12int_d=CV_INTERVIEW_DATE_D_2008;   label r12int_d = "CV_INTERVIEW_DATE 2008";
   r12int_m=CV_INTERVIEW_DATE_M_2008;   label r12int_m = "CV_INTERVIEW_DATE 2008";
   r12int_y=CV_INTERVIEW_DATE_Y_2008;   label r12int_y = "CV_INTERVIEW_DATE 2008";  
   r13int_d=CV_INTERVIEW_DATE_D_2009;   label r13int_d = "CV_INTERVIEW_DATE 2009";
   r13int_m=CV_INTERVIEW_DATE_M_2009;   label r13int_m = "CV_INTERVIEW_DATE 2009";
   r13int_y=CV_INTERVIEW_DATE_Y_2009;   label r13int_y = "CV_INTERVIEW_DATE 2009";  

   r0int_d=CV_INTERVIEW_DATE_D;   label r0int_d = "CV_INTERVIEW_DATE 2010";
   r0int_m=CV_INTERVIEW_DATE_M;   label r0int_m = "CV_INTERVIEW_DATE 2010";
   r0int_y=CV_INTERVIEW_DATE_Y;   label r0int_y = "CV_INTERVIEW_DATE 2010";

   r1int=CV_INTWK_R1;
   r2int=CV_INTWK_R2;
   r3int=CV_INTWK_R3;
   r4int=CV_INTWK_R4;
   r5int=CV_INTWK_R5;
   r6int=CV_INTWK_R6;
   r7int=CV_INTWK_R7;
   r8int=CV_INTWK_R8;
   r9int=CV_INTWK_R9;
   r10int=CV_INTWK_R10;
   r11int=CV_INTWK_R11;
   r12int=CV_INTWK_R12;
   r13int=CV_INTWK_R13;
   
if CV_INTERVIEW_DATE_Y>0 then r0mdy=mdy(CV_INTERVIEW_DATE_M,CV_INTERVIEW_DATE_D,CV_INTERVIEW_DATE_Y);

begmdy=mdy(01,01,1980);
r0int=intck('week',begmdy,r0mdy)+1;
 
if r0int=. then r0int=-5; label r0int='CV_INTWK_R14';

keep pubid
     CV_INTERVIEW_DATE_D
     CV_INTERVIEW_DATE_M
     CV_INTERVIEW_DATE_Y
     r0:
     r1int:
     r2int:
     r3int:
     r4int:
     r5int:
     r6int:
     r7int:
     r8int:
     r9int:
     r10int:
     r11int:
     r12int:
     r13int:
;

proc means n mean min max data=emp_int;
title2 'Emp_int';
run;

data emp_week; merge two emp_bday emp_int; by pubid;
if R0int>-5;
*if pubid=2032 then T4735700=200903;
*if pubid=6133 then T4735700=200902;

* Establish dli week;
array int_d     r1int_d r2int_d r3int_d r4int_d r5int_d r6int_d r7int_d
                r8int_d r9int_d r10int_d r11int_d r12int_d r13int_d;
array int_m     r1int_m r2int_m r3int_m r4int_m r5int_m r6int_m r7int_m
                r8int_m r9int_m r10int_m r11int_m r12int_m r13int_m;
array int_y     r1int_y r2int_y r3int_y r4int_y r5int_y r6int_y r7int_y
                r8int_y r9int_y r10int_y r11int_y r12int_y r13int_y;
array intwk     r1int -- r13int;

C=0;
do over int_y; C+1;
  if int_y>0 then do;
      dli_y=int_y;
    dli_m=int_m;
    dli_d=int_d;
    dliwk=intwk;
    dli_r=C;
  end;                
  dlimdy=mdy(dli_m,dli_d,dli_y);
end;

wkssli=r0int-dliwk;

* ostartm = "old" start dates, and startm the start dates with imputed values;   
array ostartm  (j) &R0STAM;   
array ostartd  (j) &R0STAD;   
array ostarty  (j) &R0STAY;  
array ostopm   (j) &R0STOM;
array ostopd   (j) &R0STOD;
array ostopy   (j) &R0STOY;
array UID      (j) &R0UID;
array self     (j) &R0SEL;
array milflag  (j) &R0MIL;

array startm   (j) starm01-starm09;
array startd   (j) stard01-stard09;       
array starty   (j) stary01-stary09;       
array stopm    (j) stopm01-stopm09;       
array stopd    (j) stopd01-stopd09;       
array stopy    (j) stopy01-stopy09;
array smofl    (j) smof01-smof09;     * dummy=1 when start month imputed;        
array emofl    (j) emof01-emof09;     * dummy=1 when stop month imputed;     

array _strmdy  (j) _strmdy01-_strmdy09;
array _stpmdy  (j) _stpmdy01-_stpmdy09;
array _startwk (j) starw01-starw09;
array _stopwk  (j) stopw01-stopw09;

begmdy=mdy(01,01,1980);
_1994mdy=mdy(01,01,1994);
_1995mdy=mdy(01,01,1995);
_1996mdy=mdy(01,01,1996);
_1997mdy=mdy(01,01,1997);
_1998mdy=mdy(01,01,1998);
_1999mdy=mdy(01,01,1999);
_2000mdy=mdy(01,01,2000);
_2001mdy=mdy(01,01,2001);
_2002mdy=mdy(01,01,2002);
_2003mdy=mdy(01,01,2003);
_2004mdy=mdy(01,01,2004);
_2005mdy=mdy(01,01,2005);
_2006mdy=mdy(01,01,2006);
_2007mdy=mdy(01,01,2007);
_2008mdy=mdy(01,01,2008);
_2009mdy=mdy(01,01,2009);
_2010mdy=mdy(01,01,2010);
_2011mdy=mdy(01,01,2011);

wk1_1994=intck('week',begmdy,_1994mdy)+1; label wk1_1994='Continuous week 1/1/94';
wk1_1995=intck('week',begmdy,_1995mdy)+1; label wk1_1995='Continuous week 1/1/95';
wk1_1996=intck('week',begmdy,_1996mdy)+1; label wk1_1996='Continuous week 1/1/96';
wk1_1997=intck('week',begmdy,_1997mdy)+1; label wk1_1997='Continuous week 1/1/97';
wk1_1998=intck('week',begmdy,_1998mdy)+1; label wk1_1998='Continuous week 1/1/98';
wk1_1999=intck('week',begmdy,_1999mdy)+1; label wk1_1999='Continuous week 1/1/99';
wk1_2000=intck('week',begmdy,_2000mdy)+1; label wk1_2000='Continuous week 1/1/00';
wk1_2001=intck('week',begmdy,_2001mdy)+1; label wk1_2001='Continuous week 1/1/01';
wk1_2002=intck('week',begmdy,_2002mdy)+1; label wk1_2002='Continuous week 1/1/02';
wk1_2003=intck('week',begmdy,_2003mdy)+1; label wk1_2003='Continuous week 1/1/03';        
wk1_2004=intck('week',begmdy,_2004mdy)+1; label wk1_2004='Continuous week 1/1/04';
wk1_2005=intck('week',begmdy,_2005mdy)+1; label wk1_2005='Continuous week 1/1/05';
wk1_2006=intck('week',begmdy,_2006mdy)+1; label wk1_2006='Continuous week 1/1/06';
wk1_2007=intck('week',begmdy,_2007mdy)+1; label wk1_2007='Continuous week 1/1/07';   
wk1_2008=intck('week',begmdy,_2008mdy)+1; label wk1_2008='Continuous week 1/1/08';
wk1_2009=intck('week',begmdy,_2009mdy)+1; label wk1_2009='Continuous week 1/1/09';
wk1_2010=intck('week',begmdy,_2010mdy)+1; label wk1_2010='Continuous week 1/1/10';
wk1_2011=intck('week',begmdy,_2011mdy)+1; label wk1_2011='Continuous week 1/1/11';

do j=1 to 9;
if uid ge 9701 then do;
    if ostartm>0 and ostartd>0 and ostarty>1979 then _strmdy=mdy(ostartm,ostartd,ostarty);
    if ostartm>0 and ostartd in (-1,-2,-3) and ostarty>1979 then _strmdy=mdy(ostartm,1,ostarty);
    if ostartm in (-1,-2,-3) and ostartd>0 and ostarty>1979 then _strmdy=mdy(1,ostartd,ostarty);
    if ostartm in (-1,-2,-3) and ostartd in (-1,-2,-3) and ostarty>1979 then _strmdy=mdy(1,1,ostarty);
    if ostopm>0 and ostopd>0 and ostopy>1979 then _stpmdy=mdy(ostopm,ostopd,ostopy);
    if ostopm>0 and ostopd in (-1,-2,-3) and ostopy>1979 then _stpmdy=mdy(ostopm,28,ostopy);
    if ostopm in (-1,-2,-3) and ostopd>0 and ostopy>1979 then _stpmdy=mdy(12,ostopd,ostopy);
    if ostopm in (-1,-2,-3) and ostopd in (-1,-2,-3) and ostopy>1979 then _stpmdy=mdy(12,28,ostopy);

    *disregard jobs where startdate>stopdate;
    if _strmdy>0 and _stpmdy>0 and _strmdy>_stpmdy then do;
        _strmdy=.; _stpmdy=.;
    end;

    if _strmdy>0 then _startwk=intck('week',begmdy,_strmdy)+1;
    if _stpmdy ge dlimdy then _stopwk =intck('week',begmdy,_stpmdy)+1;

    if 9701 le uid<201000 and _startwk>0 and dliwk>_startwk then _startwk=dliwk;
    *if 9701 le uid<200900 and _stopwk>0 and dliwk>_stopwk then _stopwk=dliwk;

    *for jobs with start/stop on/after int set start/stop to week before int;
    if _stopwk ge r0int then _stopwk=r0int-1;
    if _startwk ge r0int then _startwk=r0int-1;
    if ostarty in (-1,-2,-3,-4) then _startwk=-3;
    if ostopy in (-1,-2,-3,-4) then _stopwk=-3;
    if _startwk>0 and _stopwk>0 and _startwk>_stopwk then _startwk=_stopwk;
end;
end;

* Define new start and stop dates;
do j=1 to 9;
    if uid ge 9701 then do;
        startm=ostartm;
        startd=ostartd;
        starty=ostarty;         
        stopm=ostopm;   
        stopd=ostopd;   
        stopy=ostopy;
    end;
end;

*Impute missing start day to 1, missing stop day to 28,
 missing start month to 1(Jan), missing stop month to 12(Dec);
do over starty;
   if starty>0 then do;      
      if startd<=0 then startd=1;
      if startm<=0 then do;
        startm=1;
        smofl=1;
      end;
   end;
end;
 
do over stopy;
   if stopy>0 then do;  
      if stopd<=0 then stopd=28;
      if stopm<=0 then do;
        stopm=12;
        emofl=1;
      end;

      * stop month and day not to exceed the interview date;
      if stopy=r0int_y and stopm=r0int_m and stopd>r0int_d then stopd=r0int_d;       
      if stopy=r0int_y and stopm>r0int_m then do;
         stopm=r0int_m;
         stopd=r0int_d;
      end;
   end;
end;

* All jobs reported in earlier rounds have startdates updated to dli;
do j=1 to 9;    
  if 9700<uid<201000 and startd>-4 then do;
     if starty=dli_y and startm=dli_m and startd<dli_d and starty>0 then do;
        startd=dli_d;         
     end;    
     if starty=dli_y and startm<dli_m and starty>0 then do;
        startm=dli_m;
        startd=dli_d;        
     end;    
     if starty<dli_y and starty>0 then do;
        starty=dli_y;
        startm=dli_m;
        startd=dli_d;                
    end;        
  end;     
end;

*job start week is Jan.1 of year respondent 18th birthday for self-employed jobs;
*no cases this round;
array bself (j) bself01-bself09;

do over _startwk;
   if milflag ne 1 and self=1 and 0<_startwk<=(ag18jan-1) then do;
      bself=1;
      _startwk=ag18jan;
      starty=birthyr+18;
      startm=1;
      startd=1;
   end;
end;

*Check for back-reporters, i.e. a new job that begins before the last interview date;
do over UID;
   if milflag ne 1 and uid>201000 then do;
       if _startwk<r13int and _startwk>0 and r13int=dliwk then do; back13=1; end;
       if _startwk<r12int and _startwk>0 and r12int=dliwk then do; back12=1; end;
       if _startwk<r11int and _startwk>0 and r11int=dliwk then do; back11=1; end;
       if _startwk<r10int and _startwk>0 and r10int=dliwk then do; back10=1; end;
       if _startwk<r9int and _startwk>0 and r9int=dliwk then do; back9=1; end;
       if _startwk<r8int and _startwk>0 and r8int=dliwk then do; back8=1; end;
       if _startwk<r7int and _startwk>0 and r7int=dliwk then do; back7=1; end;
       if _startwk<r6int and _startwk>0 and r6int=dliwk then do; back6=1; end;
       if _startwk<r5int and _startwk>0 and r5int=dliwk then do; back5=1; end;
       if _startwk<r4int and _startwk>0 and r4int=dliwk then do; back4=1; end;
       if _startwk<r3int and _startwk>0 and r3int=dliwk then do; back3=1; end;
       if _startwk<r2int and _startwk>0 and r2int=dliwk then do; back2=1; end;
       if _startwk<r1int and _startwk>0 and r1int=dliwk then do; back1=1; end;
   end;
end;
 
array bstart (j) bstar01-bstar09;

back=0;
do over UID;
   if milflag ne 1 and uid>201000 and _startwk<dliwk and _startwk>0 and dliwk>0 then do;
      back=back+1;
      bstart=_startwk;
   end;
end;

*Find bstar (the earliest nonmilitary start date) for this round.
 Military jobs not included in starw, earliest start date is back reported job;
bstar=min(bstar01,bstar02,bstar03,bstar04,bstar05,bstar06,bstar07,bstar08,bstar09);
label bstar='earliest start week';

proc freq;table bstar;

proc means n mean min max data=emp_week;
var pubid &STARM &STARD &STARY &starw &STOPM &STOPD &STOPY &stopw
    &smof &emof  &R0mil &R0uid &R0sel dliwk dli_r bself01-bself09
    back back1-back12 bstar01-bstar09 bstar
    wk1_1994-wk1_2010 dlimdy _stpmdy01-_stpmdy09;
title2 'Emp_week';
run;

data emp_gaps;
merge two emp_bday emp_int emp_week; by pubid;
if r0int>-5;
 
* ENT BEG DATE (SELF-EMP WJGAP),1 ENT BEG DT +1 GAP S-EMP WJGAP,2-11;
array sbgdy  &E10591201D &E10591402D &E10591403D &E10591404D &E10591405D &E10591406D &E10591407D &E10591408D &E10591409D &E10591410D &E10591411D &E10591412D &E10591413D;
array sbgmo  &E10591201M &E10591402M &E10591403M &E10591404M &E10591405M &E10591406M &E10591407M &E10591408M &E10591409M &E10591410M &E10591411M &E10591412M &E10591413M;                                                                                     
array sbgyr  &E10591201Y &E10591402Y &E10591403Y &E10591404Y &E10591405Y &E10591406Y &E10591407Y &E10591408Y &E10591409Y &E10591410Y &E10591411Y &E10591412Y &E10591413Y;                                                                                     
array segdy  &E10591601D &E10591602D &E10591603D &E10591604D &E10591605D &E10591606D &E10591607D &E10591608D &E10591609D &E10591610D &E10591611D &E10591612D &E10591613D;                                                                                     
array segmo  &E10591601M &E10591602M &E10591603M &E10591604M &E10591605M &E10591606M &E10591607M &E10591608M &E10591609M &E10591610M &E10591611M &E10591612M &E10591613M;                                                                                    
array segyr  &E10591601Y &E10591602Y &E10591603Y &E10591604Y &E10591605Y &E10591606Y &E10591607Y &E10591608Y &E10591609Y &E10591610Y &E10591611Y &E10591612Y &E10591613Y;

* ENT BEG M/D/Y WJGAP,1  ENT BEG M/D/Y NEXT WJGAP,2-13;
array bgdy   &E10220001D &E10240002D &E10240003D &E10240004D &E10240005D &E10240006D &E10240007D &E10240008D &E10240009D &E10240010D &E10240011D &E10240012D &E10240013D;  
array bgmo   &E10220001M &E10240002M &E10240003M &E10240004M &E10240005M &E10240006M &E10240007M &E10240008M &E10240009M &E10240010M &E10240011M &E10240012M &E10240013M;                                                                         
array bgyr   &E10220001Y &E10240002Y &E10240003Y &E10240004Y &E10240005Y &E10240006Y &E10240007Y &E10240008Y &E10240009Y &E10240010Y &E10240011Y &E10240012Y &E10240013Y;                                                                                                     
array egdy   &E10270001D &E10270002D &E10270003D &E10270004D &E10270005D &E10270006D &E10270007D &E10270008D &E10270009D &E10270010D &E10270011D &E10270012D &E10270013D;                                                                                      
array egmo   &E10270001M &E10270002M &E10270003M &E10270004M &E10270005M &E10270006M &E10270007M &E10270008M &E10270009M &E10270010M &E10270011M &E10270012M &E10270013M;                                                                                      
array egyr   &E10270001Y &E10270002Y &E10270003Y &E10270004Y &E10270005Y &E10270006Y &E10270007Y &E10270008Y &E10270009Y &E10270010Y &E10270011Y &E10270012Y &E10270013Y;                                                                                  

array bgfl    &BGFL_01 &BGFL_02 &BGFL_03 &BGFL_04 &BGFL_05 &BGFL_06 &BGFL_07 &BGFL_08 &BGFL_09 &BGFL_10 &BGFL_11 &BGFL_12 &BGFL_13;
array egfl    &EGFL_01 &EGFL_02 &EGFL_03 &EGFL_04 &EGFL_05 &EGFL_06 &EGFL_07 &EGFL_08 &EGFL_09 &EGFL_10 &EGFL_11 &EGFL_12 &EGFL_13;

*YEMP SELF EMPLOYED (ROS ITEM);
array self    &R0sel &R0sel &R0sel &R0sel &R0sel &R0sel &R0sel &R0sel &R0sel &R0sel &R0sel &R0sel &R0sel;              
array UID     &R0UID &R0UID &R0UID &R0UID &R0UID &R0UID &R0UID &R0UID &R0UID &R0UID &R0UID &R0UID &R0UID;
array milflag &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL &R0MIL;
array stary   &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY &R0STAY;  
array starm   &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM &R0STAM;  
array stard   &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD &R0STAD;
array stopy   &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY &R0STOY;  
array stopm   &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM &R0STOM;  
array stopd   &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD &R0STOD;                                                   
array starw   &STARW &STARW &STARW &STARW &STARW &STARW &STARW &STARW &STARW &STARW &STARW &STARW &STARW;
array stopw   &stopW &stopW &stopW &stopW &stopW &stopW &stopW &stopW &stopW &stopW &stopW &stopW &stopW;    
array smof    &smof &smof &smof &smof &smof &smof &smof &smof &smof &smof &smof &smof &smof;
array emof    &emof &emof &emof &emof &emof &emof &emof &emof &emof &emof &emof &emof &emof;
 
* Missing gap days (start and stop) imputed to 1 if only day is missing;
do over bgyr;                                                                                                         
  if bgyr>0 then do;                                                                                                 
    if bgmo>0 and bgdy<=0 then bgdy=1;
    if bgyr=stary and bgmo=starm and bgdy<stard then bgdy=stard;                                              
  end;   
  if sbgyr>0 then do;                                                                                                 
    if sbgmo>0 and sbgdy<=0 then sbgdy=1;
    if sbgyr=stary and sbgmo=starm and sbgdy<stard then sbgdy=stard;                                              
  end;                                                            
end;                                                                                                                                                                                  
do over egyr;                                                                                                         
  if egyr>0 then do;                                                                                                 
    if egmo>0 and egdy<=0 then egdy=1;                                                             
    if egyr=stopy and egmo=stopm and stopd>0 and egdy>stopd then egdy=stopd;                                                                                                            
  end;  
  if segyr>0 then do;                                                                                                 
    if segmo>0 and segdy<=0 then segdy=1;                                                             
    if segyr=stopy and segmo=stopm and stopd>0 and segdy>stopd then segdy=stopd;                                                                                                            
  end;                  
end;        

*Set flag for gap that has invalid dates;
do over bgyr;   
   if milflag ne 1 and ((-4 < bgmo < 0)  or (-4 < bgyr <0)) then bgfl=1;
   if milflag ne 1 and ((-4 < sbgmo < 0)  or (-4 < sbgyr <0)) then bgfl=1;
   if milflag ne 1 and ((-4 < egyr < 0) or (-4 < egmo < 0)) then egfl=1;
   if milflag ne 1 and ((-4 < segyr < 0) or (-4 < segmo < 0)) then egfl=1;
end;                                                                                                          
                                                                                                                                                                            
array _bgmdy   &_BGMDY_01 &_BGMDY_02 &_BGMDY_03 &_BGMDY_04 &_BGMDY_05 &_BGMDY_06 &_BGMDY_07 &_BGMDY_08 &_BGMDY_09 &_BGMDY_10 &_BGMDY_11 &_BGMDY_12 &_BGMDY_13;
array _egmdy   &_EGMDY_01 &_EGMDY_02 &_EGMDY_03 &_EGMDY_04 &_EGMDY_05 &_EGMDY_06 &_EGMDY_07 &_EGMDY_08 &_EGMDY_09 &_EGMDY_10 &_EGMDY_11 &_EGMDY_12 &_EGMDY_13;
array _gdays   &_gdays_01 &_gdays_02 &_gdays_03 &_gdays_04 &_gdays_05 &_gdays_06 &_gdays_07 &_gdays_08 &_gdays_09 &_gdays_10 &_gdays_11 &_gdays_12 &_gdays_13;                 
array _bgap    &BGAP_01 &BGAP_02 &BGAP_03 &BGAP_04 &BGAP_05 &BGAP_06 &BGAP_07 &BGAP_08 &BGAP_09 &BGAP_10 &BGAP_11 &BGAP_12 &BGAP_13;
array _egap    &EGAP_01 &EGAP_02 &EGAP_03 &EGAP_04 &EGAP_05 &EGAP_06 &EGAP_07 &EGAP_08 &EGAP_09 &EGAP_10 &EGAP_11 &EGAP_12 &EGAP_13;

begmdy=mdy(01,01,1980);
dlimdy=mdy(dli_m,dli_d,dli_y);

do over bgyr;
    if milflag ne 1 and uid ge 9701 then do;
        *Count the number of days from January 1, 1960 (=0), to the gap begin and end dates;
        if bgmo>0 and bgdy>0 and bgyr>1979 then _bgmdy=mdy(bgmo,bgdy,bgyr);
        if sbgmo>0 and sbgdy>0 and sbgyr>1979 then _bgmdy=mdy(sbgmo,sbgdy,sbgyr);

        *Fill missing gap begin day with 1;
        if bgmo>0 and bgdy in (-1,-2,-3) and bgyr>1979 then _bgmdy=mdy(bgmo,1,bgyr);
        if sbgmo>0 and sbgdy in (-1,-2,-3) and sbgyr>1979 then _bgmdy=mdy(sbgmo,1,sbgyr);

        if egmo>0 and egdy>0 and egyr>1979 then _egmdy=mdy(egmo,egdy,egyr);
        if segmo>0 and segdy>0 and segyr>1979 then _egmdy=mdy(segmo,segdy,segyr);

        *Fill missing gap end day with 1;
        if egmo>0 and egdy in (-1,-2,-3) and egyr>1979 then _egmdy=mdy(egmo,1,egyr);
        if segmo>0 and segdy in (-1,-2,-3) and segyr>1979 then _egmdy=mdy(segmo,1,segyr);

        *And count the number of days in the gap;
        if _egmdy>0 and _bgmdy>0 then _gdays=_egmdy-_bgmdy+1;

        *Count the number of weeks from Jan 1 1980 to gap begin week
          and to gap end week to set the week numbers;
        if _bgmdy>0 then _bgap=intck('week',begmdy,_bgmdy)+1;
        if _egmdy>0 then _egap =intck('week',begmdy,_egmdy)+1;

        * Omit gap start and stop dates for gaps less than one work week (5 days);
        if _gdays ne . and _gdays<5 then do;
            _bgap=.; _egap=.;
        end;

        *Recode the gap begin week and the gap end week to eliminate partial weeks working;
          if _egap>_bgap+1 then _bgap=_bgap+1;
          if _egap>_bgap then _egap=_egap-1;  

        * disregard any entire gap before/after job;
        if _bgap>0 and (_bgap>stopw or _bgap>r0int) then do;
               _bgap=.; _egap=.; bgfl=.; egfl=.;
        end;
        if _egap>0 and (_egap<starw or _egap<dliwk) then do;
               _bgap=.; _egap=.; bgfl=.; egfl=.;
        end;

        *A gap end after the job ends is reset;
        if stopw>0 and _egap>stopw then _egap=stopw;
    end;
end;    

proc means n mean min max data=emp_gaps;
var pubid dlimdy _stpmdy01-_stpmdy09
    BGAP01_01-BGAP01_13 EGAP01_01-EGAP01_13 BGFL01_01-BGFL01_13 EGFL01_01-EGFL01_13
    BGAP02_01-BGAP02_09 EGAP02_01-EGAP02_09 BGFL02_01-BGFL02_09 EGFL02_01-EGFL02_09
    BGAP03_01-BGAP03_04 EGAP03_01-EGAP03_04 BGFL03_01-BGFL03_04 EGFL03_01-EGFL03_04
    BGAP04_01-BGAP04_02 EGAP04_01-EGAP04_02 BGFL04_01-BGFL04_02 EGFL04_01-EGFL04_02;
title2 'Emp_gaps';            
run;

data emp_countweeks;
merge two emp_bday emp_int emp_week emp_gaps; by pubid;
if r0int>-5;

*Define rd0wk as maximum of dliwk and age14wk, for employment activity this round;
rd0wk=max(dliwk,age14wk);

array job1wks  (i) _1-_892 w1_893-w1_1641;
array job2wks  (i) _1-_892 w2_893-w2_1641;
array job3wks  (i) _1-_892 w3_893-w3_1641;
array job4wks  (i) _1-_892 w4_893-w4_1641;
array job5wks  (i) _1-_892 w5_893-w5_1641;
array job6wks  (i) _1-_892 w6_893-w6_1641;
array job7wks  (i) _1-_892 w7_893-w7_1641;
array job8wks  (i) _1-_892 w8_893-w8_1641;
array job9wks  (i) _1-_892 w9_893-w9_1641;

*** TOTAL WEEKS WORKED;
           array starf     starf_1-starf_9;
           array stopf     stopf_1-stopf_9;
           array starw     &starw;
           array stopw     &stopw;   
           array stary     &R0STAY;
           array stopy     &R0STOY;               
           array smof      &smof;
           array emof      &emof;
           array bself     bself01-bself09;
           array endwk     endwk01-endwk09;
           array begwk     begwk01-begwk09;
           array bweek1    &bgap_01;
           array eweek1    &egap_01;          
           array bflag1    &bgfl_01;
           array eflag1    &egfl_01;
           array bweek2    &bgap_02;  
           array eweek2    &egap_02;
           array bflag2    &bgfl_02;
           array eflag2    &egfl_02;
           array bweek3    &bgap_03;
           array eweek3    &egap_03;
           array bflag3    &bgfl_03;
           array eflag3    &egfl_03;
           array bweek4    &bgap_04;
           array eweek4    &egap_04;   
           array bflag4    &bgfl_04;
           array eflag4    &egfl_04;
           array bweek5    &bgap_05;       
           array eweek5    &egap_05;
           array bflag5    &bgfl_05;
           array eflag5    &egfl_05;
           array bweek6    &bgap_06;       
           array eweek6    &egap_06;
           array bflag6    &bgfl_06;
           array eflag6    &egfl_06;
           array bweek7    &bgap_07;       
           array eweek7    &egap_07;
           array bflag7    &bgfl_07;
           array eflag7    &egfl_07;
           array bweek8    &bgap_08;       
           array eweek8    &egap_08;
           array bflag8    &bgfl_08;
           array eflag8    &egfl_08;
           array bweek9    &bgap_09;       
           array eweek9    &egap_09;
           array bflag9    &bgfl_09;
           array eflag9    &egfl_09;
           array bweek10   &bgap_10;  
           array eweek10   &egap_10;
           array bflag10   &bgfl_10;
           array eflag10   &egfl_10;
           array bweek11   &bgap_11;       
           array eweek11   &egap_11;
           array bflag11   &bgfl_11;
           array eflag11   &egfl_11;
           array bweek12   &bgap_12;       
           array eweek12   &egap_12;
           array bflag12   &bgfl_12;
           array eflag12   &egfl_12;
           array bweek13   &bgap_13;       
           array eweek13   &egap_13;
           array bflag13   &bgfl_13;
           array eflag13   &egfl_13;
           array milflag   &R0mil;
                     
           array jobwks    job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks job9wks;                        
                                   
           do over starf;
             if milflag=1 then do;
                starw=.;
                stopw=.;
             end;
             if starw=-3 then do;
                starw=rd0wk;
                starf=1;
             end;
             if stopw=-3 then do;
                stopw=r0int-1;
                stopf=1;
             end; *using week before intwk;
             if starw ne . and smof=1 and bself ne 1 then do;
                starf=1;*smof: bad start month flag;
                if stary=1995 then begwk=835;
                if stary=1996 then begwk=887;
                if stary=1997 then begwk=939;
                if stary=1998 then begwk=991;
                if stary=1999 then begwk=1043;
                if stary=2000 then begwk=1096;
                if stary=2001 then begwk=1148;
                if stary=2002 then begwk=1200;
                if stary=2003 then begwk=1252;
                if stary=2004 then begwk=1304;    
                if stary=2005 then begwk=1357;
                if stary=2006 then begwk=1409;   
                if stary=2007 then begwk=1461;  
                if stary=2008 then begwk=1513;
                if stary=2009 then begwk=1565;
                if stary=2010 then begwk=1617;

             end;
             if stopw ne . and emof=1 then do;
                stopf=1;*emof: bad stop month flag;
                if stopy=1997 then endwk=888;
                if stopy=1998 then endwk=940;
                if stopy=1999 then endwk=992;
                if stopy=2000 then endwk=1044;
                if stopy=2001 then endwk=1097;
                if stopy=2002 then endwk=1149;
                if stopy=2003 then endwk=1201;
                if stopy=2004 then endwk=1253;   
                if stopy=2005 then endwk=1305;
                if stopy=2006 then endwk=1358;
                if stopy=2007 then endwk=1410;
                if stopy=2008 then endwk=1462;
                if stopy=2009 then endwk=1514;
                if stopy=2010 then endwk=1566;
                if stopy=2011 then endwk=1618;
                if endwk>r0int-1 then endwk=r0int-1;
             end;
           end;      
          
           do over starw;              
             do i=893 to 1641;
               jobwks=0;
             end;              
             if starw>0 and stopw>0 then do;
                do i=(starw) to (stopw);
                    jobwks=1;
                 end;
             end;
           end;             
         
           %macro ctwksgaps;
           do over bweek&g.;*bweek=bgap: begin gap, eweek=egap: end gap;            
             if bweek&g.>0 and eweek&g.>0 then do;
                do i=(bweek&g.) to (eweek&g.);
                jobwks=0;
                 end;
             end;    
             if starw ne . and bflag&g.=1 and eweek&g.>0 then do;
                do i=(starw) to (eweek&g.);
                jobwks=-3;       
                 end;
             end;
             if stopw ne . and bweek&g.>0 and eflag&g.=1 then do;
                do i=(bweek&g.) to (stopw);
                jobwks=-3;                                                 
                 end;
             end;   
             if starw ne . and bflag&g.=1 and eflag&g.=1 then do;
                do i=(starw) to (stopw);
                jobwks=-3;
                 end;
             end;
           end;
           %mend ctwksgaps;
           %let g=1; %ctwksgaps
           %let g=2; %ctwksgaps
           %let g=3; %ctwksgaps
           %let g=4; %ctwksgaps
           %let g=5; %ctwksgaps
           %let g=6; %ctwksgaps
           %let g=7; %ctwksgaps
           %let g=8; %ctwksgaps
           %let g=9; %ctwksgaps
           %let g=10; %ctwksgaps
           %let g=11; %ctwksgaps
           %let g=12; %ctwksgaps
           %let g=13; %ctwksgaps
                        
           do over starf;
             if starf=1 then do;
               do i=(starw) to min(stopw,begwk,bweek1-1,bweek2-1,eweek1+1,eweek2+1);
               jobwks=-3;
               end;
             end;
             if stopf=1 then do;
               do i=max(starw,endwk,bweek1-1,bweek2-1,eweek1+1,eweek2+1) to (stopw);
               jobwks=-3;
               end;
             end;
           end;
           
drop _1-_892;

proc means n mean min max data=emp_countweeks;
title2 'Emp_countweeks';
var pubid rd0wk r0int starf_1-starf_9 stopf_1-stopf_9
    begwk01-begwk09 endwk01-endwk09;
run;

             
data emp29_numwks(keep= pubid r0wks97-r0wks99 r0wks00-r0wks11
                         r0swks97-r0swks99 r0swks00-r0swks11
                        r0ewks97-r0ewks99 r0ewks00-r0ewks11
                        wks893-wks1641 swks893-swks1641 ewks893-ewks1641);
merge two emp_bday emp_int emp_week emp_countweeks;
by pubid; if r0int ne -5;

array job1wks  (i)  _1-_892 w1_893-w1_1641;
array job2wks  (i)  _1-_892 w2_893-w2_1641;
array job3wks  (i)  _1-_892 w3_893-w3_1641;
array job4wks  (i)  _1-_892 w4_893-w4_1641;
array job5wks  (i)  _1-_892 w5_893-w5_1641;
array job6wks  (i)  _1-_892 w6_893-w6_1641;
array job7wks  (i)  _1-_892 w7_893-w7_1641;
array job8wks  (i)  _1-_892 w8_893-w8_1641;
array job9wks  (i)  _1-_892 w8_893-w8_1641;

array alljobs  (i)  _1-_892 wks893-wks1641;
array selfjobs (i)  _1-_892 swks893-swks1641;
array empjobs  (i)  _1-_892 ewks893-ewks1641;
array self            &R0sel;
array jobwks          job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks job9wks;

do i=893 to 1641;
       alljobs=0;
    selfjobs=0;
    empjobs=0;
end;
 
do over self;
   do i=893 to 1641;
         if jobwks=1 then alljobs=jobwks;
         if jobwks=1 and self=1 then selfjobs=jobwks;
         if jobwks=1 and self=0 then empjobs=jobwks;
      if jobwks=-3 and alljobs=0 then alljobs=jobwks;   
      if jobwks=-3 and selfjobs=0 and self=1 then selfjobs=jobwks;
      if jobwks=-3 and empjobs=0  and self=0 then empjobs=jobwks;      
   end;   
end;
 
**********************************************************
** Calculate cumulative weeks on all jobs for each year **
**********************************************************;

array r0wks   r0wks97-r0wks99   r0wks00- r0wks11;
array r0swks  r0swks97-r0swks99 r0swks00-r0swks11;
array r0ewks  r0ewks97-r0ewks99 r0ewks00-r0ewks11;

* Initialize each annual cv;
do over r0wks;
    r0wks=0;    
    r0swks=0;    
    r0ewks=0;  
end;

%macro emp29a;
do i=&cw ;  
   if i ge rd0wk and i<r0int and alljobs=1  then  r0wks&yr =r0wks&yr +1;
   if i ge rd0wk and i<r0int and selfjobs=1 then r0swks&yr =r0swks&yr +1;
   if i ge rd0wk and i<r0int and empjobs=1  then r0ewks&yr =r0ewks&yr +1;  
end;
do i=&cw ;
   if i ge rd0wk and i<r0int and alljobs=-3 then r0wks&yr =-3;
   if i ge rd0wk and i<r0int and selfjobs=-3 then r0swks&yr =-3;
   if i ge rd0wk and i<r0int and empjobs=-3 then r0ewks&yr =-3;
end;
%mend emp29a;

%let yr=97; %let cw= 888 to  939; %emp29a
%let yr=98; %let cw= 940 to  991; %emp29a
%let yr=99; %let cw= 992 to 1043; %emp29a
%let yr=00; %let cw=1044 to 1096; %emp29a
%let yr=01; %let cw=1097 to 1148; %emp29a
%let yr=02; %let cw=1149 to 1200; %emp29a
%let yr=03; %let cw=1201 to 1252; %emp29a
%let yr=04; %let cw=1253 to 1304; %emp29a
%let yr=05; %let cw=1305 to 1357; %emp29a
%let yr=06; %let cw=1358 to 1409; %emp29a
%let yr=07; %let cw=1410 to 1461; %emp29a
%let yr=08; %let cw=1462 to 1513; %emp29a
%let yr=09; %let cw=1514 to 1565; %emp29a
%let yr=10; %let cw=1566 to 1617; %emp29a
%let yr=11; %let cw=1618 to 1641; %emp29a

proc means n mean min max data=emp29_numwks;
var pubid r0wks97-r0wks99 r0wks00-r0wks11 r0swks97-r0swks99 r0swks00-r0swks11
    r0ewks97-r0ewks99 r0ewks00-r0ewks11
    wks893-wks1641 swks893-swks1641 ewks893-ewks1641;
title2 'Emp29_numwks';
run;

data emp30_totwks(keep=pubid allwks selfwks empwks bcount);
merge two emp_bday emp_int emp_week emp_countweeks(keep=pubid rd0wk)
      emp29_numwks(keep=pubid wks893-wks1641 swks893-swks1641 ewks893-ewks1641);
by pubid; if r0int ne -5;

*********************************************************************************
**  Number of weeks worked at any job since last interview date                **
**  Variables created: allwks, empwks, selfwks, bcount                         **
*********************************************************************************;

array alljobs  (i)  _1-_892 wks893-wks1641;
array selfjobs (i)  _1-_892 swks893-swks1641;
array empjobs  (i)  _1-_892 ewks893-ewks1641;

** Calculate cumulative weeks on all jobs since dli;
allwks=0;
selfwks=0;
empwks=0;

label allwks='CV_WKSWK_DLI_ALL';
label selfwks='CV_WKSWK_DLI_SE';
label empwks='CV_WKSWK_DLI_ET';

do i=rd0wk to (r0int-1);
    if alljobs=1 then allwks=allwks+1;         
    if selfjobs=1 then selfwks=selfwks+1;
    if empjobs=1 then empwks=empwks+1;
end;
do i=rd0wk to (r0int-1);
    if alljobs=-3 then allwks=-3;
    if selfjobs=-3 then selfwks=-3;
    if empjobs=-3 then empwks=-3;
end;
 
** Calculate cumulative weeks before dli on all back reported jobs;
if back>0 then bcount=0; label bcount='EMP_BK_WKS_';
if bstar>0 then do;
   do i=bstar to rd0wk-1;
      if alljobs=1 then bcount=bcount+1;       
   end;
   do i=bstar to rd0wk-1;
      if alljobs=-3 then bcount=-3;       
   end;  
end;

proc means n mean min max data=emp30_totwks;
var pubid allwks selfwks empwks bcount;
title2 'Emp30_totwks';  
run;

data emp31_jobwks(keep=pubid r0w97_1 -- r0w11_9);
merge emp_int emp_countweeks;
by pubid; if r0int ne -5;

**  Number of weeks worked since dli at each current job by year
**  eg:  r0w06_3 is number of weeks since dli worked in 2006 on job3;

array job1wks  (i) _1-_892 w1_893-w1_1641;
array job2wks  (i) _1-_892 w2_893-w2_1641;
array job3wks  (i) _1-_892 w3_893-w3_1641;
array job4wks  (i) _1-_892 w4_893-w4_1641;
array job5wks  (i) _1-_892 w5_893-w5_1641;
array job6wks  (i) _1-_892 w6_893-w6_1641;
array job7wks  (i) _1-_892 w7_893-w7_1641;
array job8wks  (i) _1-_892 w8_893-w8_1641;
array job9wks  (i) _1-_892 w9_893-w9_1641;

array r0wks97  r0w97_1-r0w97_9;
array r0wks98  r0w98_1-r0w98_9;
array r0wks99  r0w99_1-r0w99_9;
array r0wks00  r0w00_1-r0w00_9;
array r0wks01  r0w01_1-r0w01_9;
array r0wks02  r0w02_1-r0w02_9;
array r0wks03  r0w03_1-r0w03_9;
array r0wks04  r0w04_1-r0w04_9;
array r0wks05  r0w05_1-r0w05_9;
array r0wks06  r0w06_1-r0w06_9;
array r0wks07  r0w07_1-r0w07_9;
array r0wks08  r0w08_1-r0w08_9;
array r0wks09  r0w09_1-r0w09_9;
array r0wks10  r0w10_1-r0w10_9;
array r0wks11  r0w11_1-r0w11_9;
array jobwks   job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks job9wks;

%macro emp31;
do over r0wks&yr;
r0wks&yr =0;
  do i=&cw ;
    if i ge rd0wk and i<r0int and jobwks=1 then r0wks&yr =r0wks&yr +1;
  end;
  do i=&cw ;
    if i ge rd0wk and i<r0int and jobwks=-3 then r0wks&yr =-3;
  end;
end;
%mend emp31;

%let yr=97; %let cw= 888 to  939; %emp31
%let yr=98; %let cw= 940 to  991; %emp31
%let yr=99; %let cw= 992 to 1043; %emp31
%let yr=00; %let cw=1044 to 1096; %emp31
%let yr=01; %let cw=1097 to 1148; %emp31
%let yr=02; %let cw=1149 to 1200; %emp31
%let yr=03; %let cw=1201 to 1252; %emp31
%let yr=04; %let cw=1253 to 1304; %emp31
%let yr=05; %let cw=1305 to 1357; %emp31
%let yr=06; %let cw=1358 to 1409; %emp31
%let yr=07; %let cw=1410 to 1461; %emp31
%let yr=08; %let cw=1462 to 1513; %emp31
%let yr=09; %let cw=1514 to 1565; %emp31
%let yr=10; %let cw=1566 to 1617; %emp31
%let yr=11; %let cw=1618 to 1641; %emp31

proc means n mean min max data=emp31_jobwks;
var pubid
    r0w98_1-r0w98_9 r0w99_1-r0w99_9
    r0w00_1-r0w00_9 r0w01_1-r0w01_9
    r0w02_1-r0w02_9 r0w03_1-r0w03_9
    r0w04_1-r0w04_9 r0w05_1-r0w05_9
    r0w06_1-r0w06_9 r0w07_1-r0w07_9
    r0w08_1-r0w08_9 r0w09_1-r0w09_9
    r0w10_1-r0w10_9 r0w11_1-r0w11_9;
title2 'Emp31_jobwks';    
run;

data emp32_jobten /*(keep=pubid r0ten1-r0ten9)*/;
merge emp_int emp_countweeks;
by pubid; if r0int ne -5;

array job1wks  (i) _1-_892 w1_893-w1_1641;
array job2wks  (i) _1-_892 w2_893-w2_1641;
array job3wks  (i) _1-_892 w3_893-w3_1641;
array job4wks  (i) _1-_892 w4_893-w4_1641;
array job5wks  (i) _1-_892 w5_893-w5_1641;
array job6wks  (i) _1-_892 w6_893-w6_1641;
array job7wks  (i) _1-_892 w7_893-w7_1641;
array job8wks  (i) _1-_892 w8_893-w8_1641;
array job9wks  (i) _1-_892 w9_893-w9_1641;

array r0ten       r0ten1-r0ten9;
array jobwks      job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks job9wks;
          
do over r0ten;
   r0ten=0;
   do i=rd0wk to (r0int-1);
      if jobwks=1 then r0ten=r0ten+1;
   end;
end;

do over r0ten;
   do i=rd0wk to (r0int-1);
     if jobwks=-3 then r0ten=-3;
   end;
end;

proc means n mean min max data=emp32_jobten;  
var pubid r0ten1-r0ten9;
title2 'Emp32_jobten';
run;

data emp33_anhours ;
merge two emp_int emp_week emp29_numwks emp31_jobwks;
by pubid; if r0int ne -5;

**  Total hours worked each year on all, self, and emp jobs
**  Eg: r0shrs99 is total hours worked on all current self employed jobs in 1999;

array self     (k) &R0sel;
array starw    (k) starw01 - starw09;
array stopw    (k) stopw01 - stopw09;
array rghrsb   (k) rghrsb01 - rghrsb09;
array rghrs    (k) rghrs01 - rghrs09;
array othrs    (k) othrs01 - othrs09;
array hours    (k) hours01 - hours09;            
array e23901   (k) &E23901;            
array e24501   (k) &E24501;             
array e34402   (k) &E34402;                    
array e34403   (k) &E34403;             
array e34428   (k) &E34428;             
array e37904   (k) &E37904;
array e38000b  (k) &E38000B;                           
array e38000f  (k) &E38000F;
array e38002   (k) &E38002;
array e38102   (k) &E38102;                          
array e38103   (k) &E38103;             
array e38105   (k) &E38105;            
array e59901   (k) &E59901;             
array e88000   (k) &E88000;             
array e88501   (k) &E88501;             
array e98402   (k) &E98402;            
array e98403   (k) &E98403;             
array e98429   (k) &E98429;

***** Initialize the number of hours per week to 0;
do k=1 to 9;
   rghrsb=0;
   rghrs=0;
   othrs=0;
   hours=0;
end;

***** Regular rghrs Per Week;
do k=1 to 9;
  if e23901 not in (.,-4,-5) then rghrsb=e23901;
  if e34402 not in (.,-4,-5) then rghrsb=e34402;     
  if e34428 not in (.,-4,-5) then rghrsb=e34428;
  if e88000 not in (.,-4,-5) then rghrsb=e88000;
  if e98402 not in (.,-4,-5) then rghrsb=e98402;
  if e98429 not in (.,-4,-5) then rghrsb=e98429;
  if e38000f not in (.,-4,-5) then rghrsb=e38000f;
 
  if e38002 in (.,-4,0) then rghrs=rghrsb;
  else if e38002 lt 0 and e38002 ne -5 then rghrs=-3;
  else if e38002 gt 0 then do;
    if rghrsb gt 0 then rghrs=rghrsb-e38002;
    else rghrs=-3;
  end;
 
  if e38000b lt 0 and e38000b not in (-4,-5,.) then rghrs=-3;
  if e38102 in (1,3) and e38103 not in (.,-4,-5) then rghrs=e38103;
  if e38102 lt 0 and e38102 not in (-4,-5, .) then rghrs=-3;
  if e37904 > -4 then rghrs=e37904;
  if e59901 > -4 then rghrs=e59901;
end;

***** Overtime Hours Per Week;
do k=1 to 9;
  if e24501 not in (.,-4,-5) then othrs=e24501;
  if e34403 not in (.,-4,-5) then othrs=e34403;
  if e88501 not in (.,-4,-5) then othrs=e88501;
  if e98403 not in (.,-4,-5) then othrs=e98403;
  if e38002 not in (.,-4,-5) then othrs=e38002;
  if e38105 not in (.,-4,-5) then othrs=e38105;
  else if e38102 lt 0 and e38102 not in (.,-4,-5) then othrs=-3;
end;

***** Total Hours Per Week;
do k=1 to 9;
  if rghrs in (-1,-2,-3) or othrs in (-1,-2,-3) then hours=-3;
  else if rghrs ge 0 and othrs ge 0 then hours=rghrs + othrs;
end;

***** Hours Per Week on back reported jobs;
if back>1 then bhours=-3; *more than one back reported job, assign -3;

array br (k) bstar01--bstar09;

do k=1 to 9;
  if back=1 and br>0 then bhours=hours;
end;

*****************************************************************
** Calculate cumulative hours on each job for each year worked**                     
*****************************************************************;  

%macro emp33;
array wks&yr (k) r0w&yr._1-r0w&yr._9;
array  ah&yr (k)  ah&yr._1- ah&yr._9;
array sah&yr (k) sah&yr._1-sah&yr._9;
array eah&yr (k) eah&yr._1-eah&yr._9;

do k=1 to 9;
  ah&yr =0;
  sah&yr =0;
  eah&yr =0;
  if hours ge 0 and wks&yr ge 0 then ah&yr =hours*wks&yr ;
  else if wks&yr =-3 or (hours in (-1,-2,-3) and wks&yr ne 0) then ah&yr =-3;
  if self=1 then sah&yr =ah&yr ;
  if self=0 then eah&yr =ah&yr ;
end;

r0hrs&yr =0; r0shrs&yr =0; r0ehrs&yr =0;
do k=1 to 9;
  if  ah&yr ge 0 then  r0hrs&yr =  r0hrs&yr +  ah&yr ;
  if sah&yr ge 0 then r0shrs&yr = r0shrs&yr + sah&yr ;
  if eah&yr ge 0 then r0ehrs&yr = r0ehrs&yr + eah&yr ;
end;

do k=1 to 9;
  if  ah&yr =-3 then  r0hrs&yr = -3;
  if sah&yr =-3 then r0shrs&yr = -3;
  if eah&yr =-3 then r0ehrs&yr = -3;
end;
%mend emp33;

%let yr=97; %emp33
%let yr=98; %emp33
%let yr=99; %emp33
%let yr=00; %emp33
%let yr=01; %emp33
%let yr=02; %emp33
%let yr=03; %emp33
%let yr=04; %emp33
%let yr=05; %emp33
%let yr=06; %emp33
%let yr=07; %emp33
%let yr=08; %emp33
%let yr=09; %emp33
%let yr=10; %emp33
%let yr=11; %emp33

proc means n mean min max data=emp33_anhours;
title2 'Emp33_anhours';
var pubid r0hrs97-r0hrs99 r0hrs00-r0hrs11 r0shrs97-r0shrs99 r0shrs00-r0shrs11
           r0ehrs97-r0ehrs99 r0ehrs00-r0ehrs11 hours01-hours09 bhours;
run;

data emp34_wksage14(keep=pubid r0wks14 r0ewks14 r0wks20 r0ewks20);
merge emp_bday emp_int emp_week emp_countweeks emp29_numwks;
by pubid; if r0int ne -5;

*r0wks14 is number of weeks worked (all jobs) since dli to age20/r0int;
*r0wks20 is number of weeks worked (all jobs) since dli/age20 to r0int;

array alljobs (i) _1-_892 wks893-wks1641;
array empjobs (i) _1-_892 ewks893-ewks1641;

end14wk=min(age20wk-1, r0int-1);
if end14wk ge rd0wk then do;
   r0wks14=0; r0ewks14=0;
   do i=rd0wk to end14wk;
      if alljobs=1 then r0wks14=r0wks14+1;
      if empjobs=1 then r0ewks14=r0ewks14+1;
   end;
   do i=rd0wk to end14wk;
      if alljobs=-3 then r0wks14=-3;
      if empjobs=-3 then r0ewks14=-3;
   end;
end;

rd20wk=max(dliwk,age20wk); r0wks20=0; r0ewks20=0;
   do i=rd20wk to (r0int-1);
      if alljobs=1 then r0wks20=r0wks20+1;
      if empjobs=1 then r0ewks20=r0ewks20+1;
   end;
   do i=rd20wk to (r0int-1);
      if alljobs=-3 then r0wks20=-3;
      if empjobs=-3 then r0ewks20=-3;     
   end;

proc means n mean min max data=emp34_wksage14;
var pubid r0wks14 r0ewks14 r0wks20 r0ewks20;
title2 'Emp34_wksage14';
run;

data emp35_hrsage14(keep=pubid r0hrs14 r0ehrs14 r0hrs20 r0ehrs20);
merge two emp_bday emp_int emp_week emp_countweeks
      emp33_anhours(keep=pubid hours01-hours09);
by pubid; if r0int ne -5;

array job1wks  (i) _1-_892 w1_893-w1_1641;
array job2wks  (i) _1-_892 w2_893-w2_1641;
array job3wks  (i) _1-_892 w3_893-w3_1641;
array job4wks  (i) _1-_892 w4_893-w4_1641;
array job5wks  (i) _1-_892 w5_893-w5_1641;
array job6wks  (i) _1-_892 w6_893-w6_1641;
array job7wks  (i) _1-_892 w7_893-w7_1641;
array job8wks  (i) _1-_892 w8_893-w8_1641;
array job9wks  (i) _1-_892 w9_893-w9_1641;

*wks1405 is number of weeks worked ages 14 -19 for job 5;
*hrs1405 is number of hours worked ages 14 -19 for job 5;
*ehrs1405 is number of employee-type job hours worked ages 14 -19 for job 5;
*wks2005 is number of weeks worked since age 20 for job 5;
*hrs2005 is the number of hours worked since age 20 for job 5;
*ehrs2005 is the number of employee-type job hours worked since age 20 for job 5;

array hours      hours01-hours09;
array self       &R0sel;   
array wks14      wks1401-wks1409;
array hrs14      hrs1401-hrs1409;
array ehrs14     ehrs1401-ehrs1409;
array wks20      wks2001-wks2009;
array hrs20      hrs2001-hrs2009;
array ehrs20     ehrs2001-ehrs2009;
array jobwks    job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks job9wks;

end14wk=min(age20wk-1, r0int-1);

* The number of hours worked before age20;
if end14wk ge rd0wk then do;
    r0hrs14=0; r0ehrs14=0;
    do over wks14;  wks14=0; hrs14=0; ehrs14=0;
         do i=rd0wk to end14wk;  
               if jobwks=1 then wks14=wks14+1;      
         end;    
         do i=rd0wk to end14wk;  
               if jobwks=-3 then wks14=-3;      
         end;
    end;
    do over hours;
          if hours ge 0 and wks14 ge 0 then hrs14=hours*wks14;
          else if wks14=-3 or (hours in (-1,-2,-3) and wks14 ne 0) then hrs14=-3;
          if self=0 then ehrs14=hrs14;
    end;
    do over hrs14;
          if hrs14 ge 0 then r0hrs14 = r0hrs14 + hrs14;
          if ehrs14 ge 0 then r0ehrs14 = r0ehrs14 + ehrs14;
    end;
    do over hrs14;
          if hrs14=-3 then r0hrs14=-3;
          if ehrs14=-3 then r0ehrs14=-3;
    end;   
end;

* The number of hours worked since age 20;
rd20wk=max(dliwk,age20wk); r0hrs20=0; r0ehrs20=0;
do over wks20; wks20=0; hrs20=0; ehrs20=0;
   do i=rd20wk to (r0int-1);
      if jobwks=1 then wks20=wks20+1;  
   end;
   do i=rd20wk to (r0int-1);
      if jobwks=-3 then wks20=-3;     
   end;
end;

do over hrs20;
  if hours ge 0 and wks20 ge 0 then hrs20=hours*wks20;
  else if wks20=-3 or (hours in (-1,-2,-3) and wks20 ne 0) then hrs20=-3;
  if self=0 then ehrs20=hrs20;
end;

do over hrs20;
  if hrs20 ge 0 then r0hrs20 = r0hrs20 + hrs20;
  if ehrs20 ge 0 then r0ehrs20 = r0ehrs20 + ehrs20;
end;

do over hrs20;
  if hrs20=-3 then r0hrs20=-3;
  if ehrs20=-3 then r0ehrs20=-3;
end;   
 
proc means n mean min max data=emp35_hrsage14;
var pubid r0hrs14 r0ehrs14 r0hrs20 r0ehrs20;
title2 'Emp35_hrsage14';
run;

data emp36_numjobs;
merge two emp_bday emp_int emp_countweeks r14.empstatus;
by pubid; if r0int ne -5;

**********************************************************************
**  Number of NEW jobs held during year                             **
**  (conditional on having worked at least 1 week during that year) **
**********************************************************************;

array job1wks  (i)  _1-_892 w1_893-w1_1641;
array job2wks  (i)  _1-_892 w2_893-w2_1641;
array job3wks  (i)  _1-_892 w3_893-w3_1641;
array job4wks  (i)  _1-_892 w4_893-w4_1641;
array job5wks  (i)  _1-_892 w5_893-w5_1641;
array job6wks  (i)  _1-_892 w6_893-w6_1641;
array job7wks  (i)  _1-_892 w7_893-w7_1641;
array job8wks  (i)  _1-_892 w8_893-w8_1641;
array job9wks  (i)  _1-_892 w9_893-w9_1641;
array empstat  (i)  _1-_730
                    EMP_STATUS_1994_01--EMP_STATUS_1994_53 EMP_STATUS_1995_01--EMP_STATUS_1995_52    
                    EMP_STATUS_1996_01--EMP_STATUS_1996_52 EMP_STATUS_1997_01--EMP_STATUS_1997_52    
                    EMP_STATUS_1998_01--EMP_STATUS_1998_52 EMP_STATUS_1999_01--EMP_STATUS_1999_52
                    EMP_STATUS_2000_01--EMP_STATUS_2000_53 EMP_STATUS_2001_01--EMP_STATUS_2001_52    
                    EMP_STATUS_2002_01--EMP_STATUS_2002_52 EMP_STATUS_2003_01--EMP_STATUS_2003_52    
                    EMP_STATUS_2004_01--EMP_STATUS_2004_52 EMP_STATUS_2005_01--EMP_STATUS_2005_53
                    EMP_STATUS_2006_01--EMP_STATUS_2006_52 EMP_STATUS_2007_01--EMP_STATUS_2007_52
                    EMP_STATUS_2008_01--EMP_STATUS_2008_52 EMP_STATUS_2009_01--EMP_STATUS_2009_52
                    EMP_STATUS_2010_01--EMP_STATUS_2010_15 _1581-_1641;
array dual_2   (i) _1-_730 _731-_750
                    EMP_DUAL_2_1994_21--EMP_DUAL_2_1994_53 EMP_DUAL_2_1995_01--EMP_DUAL_2_1995_52
                    EMP_DUAL_2_1996_01--EMP_DUAL_2_1996_52 EMP_DUAL_2_1997_01--EMP_DUAL_2_1997_52
                    EMP_DUAL_2_1998_01--EMP_DUAL_2_1998_52 EMP_DUAL_2_1999_01--EMP_DUAL_2_1999_52
                    EMP_DUAL_2_2000_01--EMP_DUAL_2_2000_53 EMP_DUAL_2_2001_01--EMP_DUAL_2_2001_52
                    EMP_DUAL_2_2002_01--EMP_DUAL_2_2002_52 EMP_DUAL_2_2003_01--EMP_DUAL_2_2003_52
                    EMP_DUAL_2_2004_01--EMP_DUAL_2_2004_52 EMP_DUAL_2_2005_01--EMP_DUAL_2_2005_53
                    EMP_DUAL_2_2006_01--EMP_DUAL_2_2006_52 EMP_DUAL_2_2007_01--EMP_DUAL_2_2007_52
                    EMP_DUAL_2_2008_01--EMP_DUAL_2_2008_52 EMP_DUAL_2_2009_01--EMP_DUAL_2_2009_52
                    EMP_DUAL_2_2010_01--EMP_DUAL_2_2010_15 _1581-_1641;
array dual_3   (i) _1-_730 _731-_795   
                    EMP_DUAL_3_1995_13--EMP_DUAL_3_1995_52 EMP_DUAL_3_1996_01--EMP_DUAL_3_1996_52
                    EMP_DUAL_3_1997_01--EMP_DUAL_3_1997_52 EMP_DUAL_3_1998_01--EMP_DUAL_3_1998_52
                    EMP_DUAL_3_1999_01--EMP_DUAL_3_1999_52 EMP_DUAL_3_2000_01--EMP_DUAL_3_2000_53
                    EMP_DUAL_3_2001_01--EMP_DUAL_3_2001_52 EMP_DUAL_3_2002_01--EMP_DUAL_3_2002_52
                    EMP_DUAL_3_2003_01--EMP_DUAL_3_2003_52 EMP_DUAL_3_2004_01--EMP_DUAL_3_2004_52
                    EMP_DUAL_3_2005_01--EMP_DUAL_3_2005_53 EMP_DUAL_3_2006_01--EMP_DUAL_3_2006_52
                    EMP_DUAL_3_2007_01--EMP_DUAL_3_2007_52 EMP_DUAL_3_2008_01--EMP_DUAL_3_2008_52
                    EMP_DUAL_3_2009_01--EMP_DUAL_3_2009_52 EMP_DUAL_3_2010_01 _1567-_1568
                    EMP_DUAL_3_2010_04--EMP_DUAL_3_2010_13 _1579-_1641;                 
array dual_4   (i)  _1-_730 _731-_843  
                    EMP_DUAL_4_1996_09--EMP_DUAL_4_1996_36 _872-_887 _888-_894
                    EMP_DUAL_4_1997_08 _896 _897 EMP_DUAL_4_1997_11--EMP_DUAL_4_1997_35 _923-_939 _940
                    EMP_DUAL_4_1998_02--EMP_DUAL_4_1998_20 _960 _961 EMP_DUAL_4_1998_23 _963-_973
                    EMP_DUAL_4_1998_35 _975-_1013 EMP_DUAL_4_1999_23--EMP_DUAL_4_1999_31 _1023-_1030
                    EMP_DUAL_4_1999_40 _1032-_1037 EMP_DUAL_4_1999_47--EMP_DUAL_4_1999_49 _1041-_1043
                    EMP_DUAL_4_2000_01--EMP_DUAL_4_2000_07 _1051-_1056 EMP_DUAL_4_2000_14 _1058-_1061
                    EMP_DUAL_4_2000_19--EMP_DUAL_4_2000_53 EMP_DUAL_4_2001_01--EMP_DUAL_4_2001_52
                    EMP_DUAL_4_2002_01--EMP_DUAL_4_2002_52 EMP_DUAL_4_2003_01--EMP_DUAL_4_2003_52
                    EMP_DUAL_4_2004_01--EMP_DUAL_4_2004_52 EMP_DUAL_4_2005_01--EMP_DUAL_4_2005_53
                    EMP_DUAL_4_2006_01--EMP_DUAL_4_2006_52 EMP_DUAL_4_2007_01--EMP_DUAL_4_2007_52
                    EMP_DUAL_4_2008_01--EMP_DUAL_4_2008_52 EMP_DUAL_4_2009_01--EMP_DUAL_4_2009_50
                    _1564-_1565 _1566-_1641;
array dual_5     (i) _1-_730 _731-_1030
                    EMP_DUAL_5_1999_40 _1032-_1101
                    EMP_DUAL_5_2001_06--EMP_DUAL_5_2001_52 EMP_DUAL_5_2002_01--EMP_DUAL_5_2002_52    
                    EMP_DUAL_5_2003_01--EMP_DUAL_5_2003_23 _1224-_1226 EMP_DUAL_5_2003_27--EMP_DUAL_5_2003_39
                    _1240-_1244 EMP_DUAL_5_2003_45--EMP_DUAL_5_2003_52 EMP_DUAL_5_2004_01--EMP_DUAL_5_2004_06     
                       _1259-_1270 EMP_DUAL_5_2004_19--EMP_DUAL_5_2004_30 _1283-_1335 EMP_DUAL_5_2005_32--EMP_DUAL_5_2005_41
                    _1346-_1352 EMP_DUAL_5_2005_49 _1354-_1368 EMP_DUAL_5_2006_12 EMP_DUAL_5_2006_13
                    _1371-_1379 EMP_DUAL_5_2006_23--EMP_DUAL_5_2006_52
                    EMP_DUAL_5_2007_01--EMP_DUAL_5_2007_52 EMP_DUAL_5_2008_01--EMP_DUAL_5_2008_33 _1495 _1496
                    EMP_DUAL_5_2008_36--EMP_DUAL_5_2008_52 EMP_DUAL_5_2009_01--EMP_DUAL_5_2009_48 _1562
                    EMP_DUAL_5_2009_50 _1564-_1565 _1566-_1641;
array dual_6     (i) _1-_730 _731-_1162
                    EMP_DUAL_6_2002_15--EMP_DUAL_6_2002_22 _1171-_1175 EMP_DUAL_6_2002_28--EMP_DUAL_6_2002_31
                    _1180-_1222 EMP_DUAL_6_2003_23 _1224-_1380 EMP_DUAL_6_2006_24 _1382-_1415
                    EMP_DUAL_6_2007_07--EMP_DUAL_6_2007_52 EMP_DUAL_6_2008_01--EMP_DUAL_6_2008_32 _1494-_1513
                    _1514 EMP_DUAL_6_2009_02--EMP_DUAL_6_2009_47 _1561_1565 _1566-_1641;
array dual_7     (i) _1-_730 _731-_1440
                     EMP_DUAL_7_2007_32--EMP_DUAL_7_2007_52 EMP_DUAL_7_2008_01--EMP_DUAL_7_2008_31 _1493-_1513
                    _1514 EMP_DUAL_7_2009_02--EMP_DUAL_7_2009_47 _1561_1565 _1566-_1641;
array dual_8     (i)  _1-_730 _731-_1449
                     EMP_DUAL_8_2007_41--EMP_DUAL_8_2007_50 _1460-_1559 EMP_DUAL_8_2009_47
                     _1561-_1565 _1566-_1641;
array self           &r0sel;
array uid            &r0uid;
array jobwks         job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks job9wks;

%macro emp36;
array r0j&yr r0j&yr.01 -r0j&yr.09;
array r0d&yr r0d&yr.01 -r0d&yr.09;
array r0s&yr r0s&yr.01 -r0s&yr.09;
array r0e&yr r0e&yr.01 -r0e&yr.09;

do over r0j&yr;
    r0j&yr =0;
    r0s&yr =0;
    r0e&yr =0;
end;

do over r0j&yr;
  do i=&cw;
    if i ge rd0wk and i<r0int and jobwks=-3 then r0j&yr =-3;
    if i ge rd0wk and i<r0int and jobwks=-3 and self=1 then r0s&yr =-3;
    if i ge rd0wk and i<r0int and jobwks=-3 and self=0 then r0e&yr =-3;
  end;
  do i=&cw;
    if i ge rd0wk and i<r0int and jobwks=1 then r0j&yr =uid;
    if i ge rd0wk and i<r0int and jobwks=1 and self=1 then r0s&yr =uid;
    if i ge rd0wk and i<r0int and jobwks=1 and self=0 then r0e&yr =uid;
  end;
  do i=&cw;
      if i lt rd0wk and empstat=r0j&yr then r0d&yr =r0j&yr;
      if i lt rd0wk and dual_2 =r0j&yr then r0d&yr =r0j&yr;
      if i lt rd0wk and dual_3 =r0j&yr then r0d&yr =r0j&yr;
      if i lt rd0wk and dual_4 =r0j&yr then r0d&yr =r0j&yr;
      if i lt rd0wk and dual_5 =r0j&yr then r0d&yr =r0j&yr;
      if i lt rd0wk and dual_6 =r0j&yr then r0d&yr =r0j&yr;
      if i lt rd0wk and dual_7 =r0j&yr then r0d&yr =r0j&yr;
      if i lt rd0wk and dual_8 =r0j&yr then r0d&yr =r0j&yr;
  end;
end;
 
r0job&yr =0;
r0emp&yr =0;
r0self&yr=0;
if r0job&yr ge 0 and r0j&yr.01>9700 and r0j&yr.01 ne r0d&yr.01
   then r0job&yr =r0job&yr +1; if r0j&yr.01=-3 then r0job&yr =-3;
if r0job&yr ge 0 and r0j&yr.02>9700 and r0j&yr.02 ne r0d&yr.02
   then r0job&yr =r0job&yr +1; if r0j&yr.02=-3 then r0job&yr =-3;
if r0job&yr ge 0 and r0j&yr.03>9700 and r0j&yr.03 ne r0d&yr.03
   then r0job&yr =r0job&yr +1; if r0j&yr.03=-3 then r0job&yr =-3;
if r0job&yr ge 0 and r0j&yr.04>9700 and r0j&yr.04 ne r0d&yr.04
   then r0job&yr =r0job&yr +1; if r0j&yr.04=-3 then r0job&yr =-3;
if r0job&yr ge 0 and r0j&yr.05>9700 and r0j&yr.05 ne r0d&yr.05
   then r0job&yr =r0job&yr +1; if r0j&yr.05=-3 then r0job&yr =-3;
if r0job&yr ge 0 and r0j&yr.06>9700 and r0j&yr.06 ne r0d&yr.06
   then r0job&yr =r0job&yr +1; if r0j&yr.06=-3 then r0job&yr =-3;
if r0job&yr ge 0 and r0j&yr.07>9700 and r0j&yr.07 ne r0d&yr.07
   then r0job&yr =r0job&yr +1; if r0j&yr.07=-3 then r0job&yr =-3;
if r0job&yr ge 0 and r0j&yr.08>9700 and r0j&yr.08 ne r0d&yr.08
   then r0job&yr =r0job&yr +1; if r0j&yr.08=-3 then r0job&yr =-3;
if r0job&yr ge 0 and r0j&yr.09>9700 and r0j&yr.09 ne r0d&yr.09
   then r0job&yr =r0job&yr +1; if r0j&yr.09=-3 then r0job&yr =-3;
   
if r0emp&yr ge 0 and r0e&yr.01>9700 and r0e&yr.01 ne r0d&yr.01
   then r0emp&yr =r0emp&yr +1; if r0e&yr.01=-3 then r0emp&yr =-3;
if r0emp&yr ge 0 and r0e&yr.02>9700 and r0e&yr.02 ne r0d&yr.02
   then r0emp&yr =r0emp&yr +1; if r0e&yr.02=-3 then r0emp&yr =-3;
if r0emp&yr ge 0 and r0e&yr.03>9700 and r0e&yr.03 ne r0d&yr.03
   then r0emp&yr =r0emp&yr +1; if r0e&yr.03=-3 then r0emp&yr =-3;
if r0emp&yr ge 0 and r0e&yr.04>9700 and r0e&yr.04 ne r0d&yr.04
   then r0emp&yr =r0emp&yr +1; if r0e&yr.04=-3 then r0emp&yr =-3;
if r0emp&yr ge 0 and r0e&yr.05>9700 and r0e&yr.05 ne r0d&yr.05
   then r0emp&yr =r0emp&yr +1; if r0e&yr.05=-3 then r0emp&yr =-3;
if r0emp&yr ge 0 and r0e&yr.06>9700 and r0e&yr.06 ne r0d&yr.06
   then r0emp&yr =r0emp&yr +1; if r0e&yr.06=-3 then r0emp&yr =-3;
if r0emp&yr ge 0 and r0e&yr.07>9700 and r0e&yr.07 ne r0d&yr.07
   then r0emp&yr =r0emp&yr +1; if r0e&yr.07=-3 then r0emp&yr =-3;
if r0emp&yr ge 0 and r0e&yr.08>9700 and r0e&yr.08 ne r0d&yr.08
   then r0emp&yr =r0emp&yr +1; if r0e&yr.08=-3 then r0emp&yr =-3;
if r0emp&yr ge 0 and r0e&yr.09>9700 and r0e&yr.09 ne r0d&yr.09
   then r0emp&yr =r0emp&yr +1; if r0e&yr.09=-3 then r0emp&yr =-3;

if r0self&yr ge 0 and r0s&yr.01>9700 and r0s&yr.01 ne r0d&yr.01
   then r0self&yr =r0self&yr +1; if r0s&yr.01=-3 then r0self&yr =-3;
if r0self&yr ge 0 and r0s&yr.02>9700 and r0s&yr.02 ne r0d&yr.02
   then r0self&yr =r0self&yr +1; if r0s&yr.02=-3 then r0self&yr =-3;
if r0self&yr ge 0 and r0s&yr.03>9700 and r0s&yr.03 ne r0d&yr.03
   then r0self&yr =r0self&yr +1; if r0s&yr.03=-3 then r0self&yr =-3;
if r0self&yr ge 0 and r0s&yr.04>9700 and r0s&yr.04 ne r0d&yr.04
   then r0self&yr =r0self&yr +1; if r0s&yr.04=-3 then r0self&yr =-3;
if r0self&yr ge 0 and r0s&yr.05>9700 and r0s&yr.05 ne r0d&yr.05
   then r0self&yr =r0self&yr +1; if r0s&yr.05=-3 then r0self&yr =-3;
if r0self&yr ge 0 and r0s&yr.06>9700 and r0s&yr.06 ne r0d&yr.06
   then r0self&yr =r0self&yr +1; if r0s&yr.06=-3 then r0self&yr =-3;
%mend emp36;

%let yr=97; %let cw= 888 to  939; %emp36
%let yr=98; %let cw= 940 to  991; %emp36
%let yr=99; %let cw= 992 to 1043; %emp36
%let yr=00; %let cw=1044 to 1096; %emp36
%let yr=01; %let cw=1097 to 1148; %emp36
%let yr=02; %let cw=1149 to 1200; %emp36
%let yr=03; %let cw=1201 to 1252; %emp36
%let yr=04; %let cw=1253 to 1304; %emp36
%let yr=05; %let cw=1305 to 1357; %emp36
%let yr=06; %let cw=1358 to 1409; %emp36
%let yr=07; %let cw=1410 to 1461; %emp36
%let yr=08; %let cw=1462 to 1513; %emp36
%let yr=09; %let cw=1514 to 1565; %emp36
%let yr=10; %let cw=1566 to 1617; %emp36
%let yr=11; %let cw=1618 to 1641; %emp36

proc means n mean min max data=emp36_numjobs; *where pubid=156;
title2 'Emp36_numjobs';
var pubid r0job97-r0job99 r0job00-r0job11
           r0emp97-r0emp99 r0emp00-r0emp11
           r0self97-r0self99 r0self00-r0self11;
run;

data emp37_numjobs14;
merge two emp_bday emp_int emp_week emp_countweeks r14.empstatus;
by pubid; if r0int ne -5;

**********************************************************************
**  Number of jobs held since age 14 & 20                           **
**  (conditional on having worked at least 1 week since age14)      **
**  Variables created: r0emp14 r0job14 r0emp20 r0job20              **
**********************************************************************;

array job1wks  (i)  _1-_892 w1_893-w1_1641;
array job2wks  (i)  _1-_892 w2_893-w2_1641;
array job3wks  (i)  _1-_892 w3_893-w3_1641;
array job4wks  (i)  _1-_892 w4_893-w4_1641;
array job5wks  (i)  _1-_892 w5_893-w5_1641;
array job6wks  (i)  _1-_892 w6_893-w6_1641;
array job7wks  (i)  _1-_892 w7_893-w7_1641;
array job8wks  (i)  _1-_892 w8_893-w8_1641;
array job9wks  (i)  _1-_892 w9_893-w9_1641;
array empstat  (i)  _1-_730
                    EMP_STATUS_1994_01 -- EMP_STATUS_1994_53 EMP_STATUS_1995_01 -- EMP_STATUS_1995_52    
                    EMP_STATUS_1996_01 -- EMP_STATUS_1996_52 EMP_STATUS_1997_01 -- EMP_STATUS_1997_52    
                    EMP_STATUS_1998_01 -- EMP_STATUS_1998_52 EMP_STATUS_1999_01 -- EMP_STATUS_1999_52
                    EMP_STATUS_2000_01 -- EMP_STATUS_2000_53 EMP_STATUS_2001_01    -- EMP_STATUS_2001_52    
                    EMP_STATUS_2002_01 -- EMP_STATUS_2002_52 EMP_STATUS_2003_01 -- EMP_STATUS_2003_52    
                    EMP_STATUS_2004_01 -- EMP_STATUS_2004_52 EMP_STATUS_2005_01 -- EMP_STATUS_2005_53
                    EMP_STATUS_2006_01 -- EMP_STATUS_2006_52 EMP_STATUS_2007_01    -- EMP_STATUS_2007_52
                    EMP_STATUS_2008_01 -- EMP_STATUS_2008_52 EMP_STATUS_2009_01 -- EMP_STATUS_2009_52
                    EMP_STATUS_2010_01 -- EMP_STATUS_2010_15 _1581-_1641;
array dual_2     (i) _1-_730 _731-_750
                    EMP_DUAL_2_1994_21 -- EMP_DUAL_2_1994_53 EMP_DUAL_2_1995_01    -- EMP_DUAL_2_1995_52
                    EMP_DUAL_2_1996_01 -- EMP_DUAL_2_1996_52 EMP_DUAL_2_1997_01 -- EMP_DUAL_2_1997_52
                    EMP_DUAL_2_1998_01 -- EMP_DUAL_2_1998_52 EMP_DUAL_2_1999_01 -- EMP_DUAL_2_1999_52
                    EMP_DUAL_2_2000_01 -- EMP_DUAL_2_2000_53 EMP_DUAL_2_2001_01 -- EMP_DUAL_2_2001_52
                    EMP_DUAL_2_2002_01 -- EMP_DUAL_2_2002_52 EMP_DUAL_2_2003_01 -- EMP_DUAL_2_2003_52
                    EMP_DUAL_2_2004_01 -- EMP_DUAL_2_2004_52 EMP_DUAL_2_2005_01 -- EMP_DUAL_2_2005_53
                    EMP_DUAL_2_2006_01 -- EMP_DUAL_2_2006_52 EMP_DUAL_2_2007_01 -- EMP_DUAL_2_2007_52
                    EMP_DUAL_2_2008_01 -- EMP_DUAL_2_2008_52 EMP_DUAL_2_2009_01 -- EMP_DUAL_2_2009_52
                    EMP_DUAL_2_2010_01 -- EMP_DUAL_2_2010_15 _1581-_1641;
array dual_3     (i) _1-_730 _731-_795   
                    EMP_DUAL_3_1995_13 -- EMP_DUAL_3_1995_52 EMP_DUAL_3_1996_01 -- EMP_DUAL_3_1996_52
                    EMP_DUAL_3_1997_01 -- EMP_DUAL_3_1997_52 EMP_DUAL_3_1998_01 -- EMP_DUAL_3_1998_52
                    EMP_DUAL_3_1999_01 -- EMP_DUAL_3_1999_52 EMP_DUAL_3_2000_01 -- EMP_DUAL_3_2000_53
                    EMP_DUAL_3_2001_01 -- EMP_DUAL_3_2001_52 EMP_DUAL_3_2002_01 -- EMP_DUAL_3_2002_52
                    EMP_DUAL_3_2003_01 -- EMP_DUAL_3_2003_52 EMP_DUAL_3_2004_01 -- EMP_DUAL_3_2004_52
                    EMP_DUAL_3_2005_01 -- EMP_DUAL_3_2005_53 EMP_DUAL_3_2006_01 -- EMP_DUAL_3_2006_52
                    EMP_DUAL_3_2007_01 -- EMP_DUAL_3_2007_52 EMP_DUAL_3_2008_01 -- EMP_DUAL_3_2008_52
                    EMP_DUAL_3_2009_01 -- EMP_DUAL_3_2009_52 EMP_DUAL_3_2010_01 _1567-_1568
                    EMP_DUAL_3_2010_04 -- EMP_DUAL_3_2010_13 _1579-_1641;                  
array dual_4     (i) _1-_730 _731-_843  
                    EMP_DUAL_4_1996_09 -- EMP_DUAL_4_1996_36 _872-_887 _888-_894
                    EMP_DUAL_4_1997_08 _896 _897 EMP_DUAL_4_1997_11 -- EMP_DUAL_4_1997_35 _923-_939 _940
                    EMP_DUAL_4_1998_02 -- EMP_DUAL_4_1998_20 _960 _961 EMP_DUAL_4_1998_23 _963-_973
                    EMP_DUAL_4_1998_35 _975-_1013 EMP_DUAL_4_1999_23 -- EMP_DUAL_4_1999_31 _1023-_1030
                    EMP_DUAL_4_1999_40 _1032-_1037 EMP_DUAL_4_1999_47 -- EMP_DUAL_4_1999_49 _1041-_1043
                    EMP_DUAL_4_2000_01 -- EMP_DUAL_4_2000_07 _1051-_1056 EMP_DUAL_4_2000_14 _1058-_1061
                    EMP_DUAL_4_2000_19 -- EMP_DUAL_4_2000_53 EMP_DUAL_4_2001_01 -- EMP_DUAL_4_2001_52
                    EMP_DUAL_4_2002_01 -- EMP_DUAL_4_2002_52 EMP_DUAL_4_2003_01 -- EMP_DUAL_4_2003_52
                    EMP_DUAL_4_2004_01 -- EMP_DUAL_4_2004_52 EMP_DUAL_4_2005_01 -- EMP_DUAL_4_2005_53
                    EMP_DUAL_4_2006_01 -- EMP_DUAL_4_2006_52 EMP_DUAL_4_2007_01 -- EMP_DUAL_4_2007_52
                    EMP_DUAL_4_2008_01 -- EMP_DUAL_4_2008_52 EMP_DUAL_4_2009_01 -- EMP_DUAL_4_2009_50
                    _1564-_1565 _1566-_1641;
array dual_5     (i) _1-_730 _731-_1030 EMP_DUAL_5_1999_40 _1032-_1101
                    EMP_DUAL_5_2001_06 -- EMP_DUAL_5_2001_52 EMP_DUAL_5_2002_01 -- EMP_DUAL_5_2002_52    
                    EMP_DUAL_5_2003_01 -- EMP_DUAL_5_2003_23 _1224-_1226 EMP_DUAL_5_2003_27    -- EMP_DUAL_5_2003_39
                    _1240-_1244 EMP_DUAL_5_2003_45 -- EMP_DUAL_5_2003_52 EMP_DUAL_5_2004_01 -- EMP_DUAL_5_2004_06     
                    _1259-_1270 EMP_DUAL_5_2004_19 -- EMP_DUAL_5_2004_30 _1283-_1335 EMP_DUAL_5_2005_32 -- EMP_DUAL_5_2005_41
                    _1346-_1352 EMP_DUAL_5_2005_49 _1354-_1368 EMP_DUAL_5_2006_12 EMP_DUAL_5_2006_13
                    _1371-_1379 EMP_DUAL_5_2006_23 -- EMP_DUAL_5_2006_52
                    EMP_DUAL_5_2007_01 -- EMP_DUAL_5_2007_52 EMP_DUAL_5_2008_01 -- EMP_DUAL_5_2008_33 _1495 _1496
                    EMP_DUAL_5_2008_36 -- EMP_DUAL_5_2008_52 EMP_DUAL_5_2009_01    -- EMP_DUAL_5_2009_48 _1562
                    EMP_DUAL_5_2009_50 _1564-_1565 _1566-_1641;
array dual_6     (i) _1-_730 _731-_1162
                    EMP_DUAL_6_2002_15 -- EMP_DUAL_6_2002_22 _1171-_1175 EMP_DUAL_6_2002_28 -- EMP_DUAL_6_2002_31
                    _1180-_1222 EMP_DUAL_6_2003_23 _1224-_1380 EMP_DUAL_6_2006_24 _1382-_1415
                    EMP_DUAL_6_2007_07 -- EMP_DUAL_6_2007_52 EMP_DUAL_6_2008_01 -- EMP_DUAL_6_2008_32 _1494-_1513
                    _1514 EMP_DUAL_6_2009_02 -- EMP_DUAL_6_2009_47 _1561_1565 _1566-_1641;
array dual_7     (i) _1-_730 _731-_1440
                    EMP_DUAL_7_2007_32 -- EMP_DUAL_7_2007_52 EMP_DUAL_7_2008_01 -- EMP_DUAL_7_2008_31 _1493-_1513
                    _1514 EMP_DUAL_7_2009_02 -- EMP_DUAL_7_2009_47 _1561_1565 _1566-_1641;
array dual_8     (i) _1-_730 _731-_1449 EMP_DUAL_8_2007_41 -- EMP_DUAL_8_2007_50 _1460-_1559 EMP_DUAL_8_2009_47
                    _1561-_1565 _1566-_1641;

***************************************************************************
** Indicate if worked at least one week on a NEW job since age 14 & 20 **
***************************************************************************;

array r0e14      r0e1401-r0e1409;
array r0j14      r0j1401-r0j1409;
array r0d14      r0d1401-r0d1409;
array r0e20      r0e2001-r0e2009;
array r0j20      r0j2001-r0j2009;
array r0d20      r0d2001-r0d2009;
array self       &R0sel;
array uid        &r0uid;
array jobwks     job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks job9wks;

end14wk=min(age20wk-1, r0int-1); *last week before age20;

* r0j14 current job worked btw age14/dli and wk before age20;
* r0e14 current employee type job worked btw age14/dli and wk before age20;

if end14wk ge rd0wk then do; r0job14=0; r0emp14=0;
   do i=rd0wk to end14wk;
        do over r0j14;
       if jobwks=-3 then r0j14=-3;
       if jobwks=-3 and self=0 then r0e14=-3;
     end;
     do over r0j14;
       if jobwks=1 then r0j14=uid;
       if jobwks=1 and self=0 then r0e14=uid;
     end;
   end;
   do i=age14wk to rd0wk-1;
        do over r0d14;
       if empstat=r0j14 then r0d14 =r0j14;
       if dual_2 =r0j14 then r0d14 =r0j14;
       if dual_3 =r0j14 then r0d14 =r0j14;
       if dual_4 =r0j14 then r0d14 =r0j14;
       if dual_5 =r0j14 then r0d14 =r0j14;
       if dual_6 =r0j14 then r0d14 =r0j14;
       if dual_7 =r0j14 then r0d14 =r0j14;
       if dual_8 =r0j14 then r0d14 =r0j14;
     end;
   end;
end;

* r0j20 current job NEW btw age20 and intv;
* r0e20 employee type job NEW btw age20 and intv;

rd20wk=max(rd0wk,age20wk);
if age20wk le r0int-1 then do; r0job20=0; r0emp20=0;
   do i=rd20wk to (r0int-1);
     do over r0j20;
       if jobwks=-3 then r0j20=-3;
       if jobwks=-3 and self=0 then r0e20=-3;
     end;
   end;
   do i=rd20wk to (r0int-1);
     do over r0j20;
      if jobwks=1 then r0j20=uid;
      if jobwks=1 and self=0 then r0e20=uid;   
     end;
   end;
   do i=age20wk to (rd20wk-1);
     do over r0d20;
       if empstat=r0j20 then r0d20 =r0j20;
       if dual_2 =r0j20 then r0d20 =r0j20;
       if dual_3 =r0j20 then r0d20 =r0j20;
       if dual_4 =r0j20 then r0d20 =r0j20;
       if dual_5 =r0j20 then r0d20 =r0j20;
       if dual_6 =r0j20 then r0d20 =r0j20;
       if dual_7 =r0j20 then r0d20 =r0j20;
       if dual_8 =r0j20 then r0d20 =r0j20;
     end;
   end;
end;
if r0emp14 ge 0 and r0e1401>9700 and r0e1401 ne r0d1401
   then r0emp14 =r0emp14 +1; if r0e1401=-3 then r0emp14 =-3;
if r0emp14 ge 0 and r0e1402>9700 and r0e1402 ne r0d1402
   then r0emp14 =r0emp14 +1; if r0e1402=-3 then r0emp14 =-3;
if r0emp14 ge 0 and r0e1403>9700 and r0e1403 ne r0d1403
   then r0emp14 =r0emp14 +1; if r0e1403=-3 then r0emp14 =-3;
if r0emp14 ge 0 and r0e1404>9700 and r0e1404 ne r0d1404
   then r0emp14 =r0emp14 +1; if r0e1404=-3 then r0emp14 =-3;
if r0emp14 ge 0 and r0e1405>9700 and r0e1405 ne r0d1405
   then r0emp14 =r0emp14 +1; if r0e1405=-3 then r0emp14 =-3;
if r0emp14 ge 0 and r0e1406>9700 and r0e1406 ne r0d1406
   then r0emp14 =r0emp14 +1; if r0e1406=-3 then r0emp14 =-3;
if r0emp14 ge 0 and r0e1407>9700 and r0e1407 ne r0d1407
   then r0emp14 =r0emp14 +1; if r0e1407=-3 then r0emp14 =-3;

if r0job20 ge 0 and r0j2001>9700 and r0j2001 ne r0d2001
   then r0job20 =r0job20 +1; if r0j2001=-3 then r0job20 =-3;
if r0job20 ge 0 and r0j2002>9700 and r0j2002 ne r0d2002
   then r0job20 =r0job20 +1; if r0j2002=-3 then r0job20 =-3;
if r0job20 ge 0 and r0j2003>9700 and r0j2003 ne r0d2003
   then r0job20 =r0job20 +1; if r0j2003=-3 then r0job20 =-3;
if r0job20 ge 0 and r0j2004>9700 and r0j2004 ne r0d2004
   then r0job20 =r0job20 +1; if r0j2004=-3 then r0job20 =-3;
if r0job20 ge 0 and r0j2005>9700 and r0j2005 ne r0d2005
   then r0job20 =r0job20 +1; if r0j2005=-3 then r0job20 =-3;
if r0job20 ge 0 and r0j2006>9700 and r0j2006 ne r0d2006
   then r0job20 =r0job20 +1; if r0j2006=-3 then r0job20 =-3;
if r0job20 ge 0 and r0j2007>9700 and r0j2007 ne r0d2007
   then r0job20 =r0job20 +1; if r0j2007=-3 then r0job20 =-3;
if r0job20 ge 0 and r0j2008>9700 and r0j2008 ne r0d2008
   then r0job20 =r0job20 +1; if r0j2008=-3 then r0job20 =-3;
if r0job20 ge 0 and r0j2009>9700 and r0j2009 ne r0d2009
   then r0job20 =r0job20 +1; if r0j2009=-3 then r0job20 =-3;

if r0emp20 ge 0 and r0e2001>9700 and r0e2001 ne r0d2001
   then r0emp20 =r0emp20 +1; if r0e2001=-3 then r0emp20 =-3;
if r0emp20 ge 0 and r0e2002>9700 and r0e2002 ne r0d2002
   then r0emp20 =r0emp20 +1; if r0e2002=-3 then r0emp20 =-3;
if r0emp20 ge 0 and r0e2003>9700 and r0e2003 ne r0d2003
   then r0emp20 =r0emp20 +1; if r0e2003=-3 then r0emp20 =-3;
if r0emp20 ge 0 and r0e2004>9700 and r0e2004 ne r0d2004
   then r0emp20 =r0emp20 +1; if r0e2004=-3 then r0emp20 =-3;
if r0emp20 ge 0 and r0e2005>9700 and r0e2005 ne r0d2005
   then r0emp20 =r0emp20 +1; if r0e2005=-3 then r0emp20 =-3;
if r0emp20 ge 0 and r0e2006>9700 and r0e2006 ne r0d2006
   then r0emp20 =r0emp20 +1; if r0e2006=-3 then r0emp20 =-3;
if r0emp20 ge 0 and r0e2007>9700 and r0e2007 ne r0d2007
   then r0emp20 =r0emp20 +1; if r0e2007=-3 then r0emp20 =-3;
if r0emp20 ge 0 and r0e2008>9700 and r0e2008 ne r0d2008
   then r0emp20 =r0emp20 +1; if r0e2008=-3 then r0emp20 =-3;
if r0emp20 ge 0 and r0e2009>9700 and r0e2009 ne r0d2009
   then r0emp20 =r0emp20 +1; if r0e2009=-3 then r0emp20 =-3;

title2 'Emp37_numjobs14';

proc means n mean min max data=emp37_numjobs14;
var pubid r0emp14 r0job20 r0emp20;
run;

data emp_array;
merge two emp_bday (keep=pubid age14wk)
      emp_int(keep=pubid r0int)
      emp33_anhours (keep=pubid hours01-hours09) emp_week emp_gaps
      emp_countweeks(keep=pubid rd0wk starf_1-starf_9 stopf_1-stopf_9
                          begwk01-begwk09 endwk01-endwk09);
by pubid;if r0int>-5;

array job1wks (i) _1-_892 wk1_893-wk1_1641;
array hourwk1 (i) _1-_892 hr1_893-hr1_1641;        
array job2wks (i) _1-_892 wk2_893-wk2_1641;
array hourwk2 (i) _1-_892 hr2_893-hr2_1641;
array job3wks (i) _1-_892 wk3_893-wk3_1641;
array hourwk3 (i) _1-_892 hr3_893-hr3_1641;        
array job4wks (i) _1-_892 wk4_893-wk4_1641;
array hourwk4 (i) _1-_892 hr4_893-hr4_1641;
array job5wks (i) _1-_892 wk5_893-wk5_1641;
array hourwk5 (i) _1-_892 hr5_893-hr5_1641;        
array job6wks (i) _1-_892 wk6_893-wk6_1641;
array hourwk6 (i) _1-_892 hr6_893-hr6_1641;
array job7wks (i) _1-_892 wk7_893-wk7_1641;
array hourwk7 (i) _1-_892 hr7_893-hr7_1641;        
array job8wks (i) _1-_892 wk8_893-wk8_1641;
array hourwk8 (i) _1-_892 hr8_893-hr8_1641;
array job9wks (i) _1-_892 wk9_893-wk9_1641;
array hourwk9 (i) _1-_892 hr9_893-hr9_1641;

* Default Settings;
do i=893 to 1641;
       job1wks=0;
    job2wks=0;
    job3wks=0;
    job4wks=0;
       job5wks=0;
    job6wks=0;
    job7wks=0;
    job8wks=0;
       job9wks=0;
       hourwk1=0;
    hourwk2=0;
    hourwk3=0;
    hourwk4=0;
       hourwk5=0;
    hourwk6=0;
    hourwk7=0;
    hourwk8=0;
       hourwk9=0;
end;

***********************************
**start and stop dates: all jobs **
***********************************;

array starw    starw01-starw09;
array stopw    stopw01-stopw09;
array starf    starf_1-starf_9;
array stopf    stopf_1-stopf_9;
array uid      &R0uid;
array staryrf  staryrf01-staryrf09;
array stopyrf  stopyrf01-stopyrf09;
array smof     smof01-smof09;
array emof     emof01-emof09;
array stary    stary01-stary09;
array stopy    stopy01-stopy09;
array begwk    begwk01-begwk09;
array endwk    endwk01-endwk09;
array r0mil    &R0mil;
array hours    hours01-hours09;
array jobwks   job1wks job2wks job3wks job4wks job5wks job6wks job7wks job8wks job9wks;
array hourwk   hourwk1 hourwk2 hourwk3 hourwk4 hourwk5 hourwk6 hourwk7 hourwk8 hourwk9;

do over starw;
  if starw=-3 and uid ne -5 then do;
    starw=rd0wk;  
    staryrf=1;
 end;    * "begwk" is . for this group;
 if stopw=-3 and uid ne -5 then do;
    stopw=r0int-1;
    stopyrf=1;
 end;    * "endwk01" is . for this group;

***********************************
*** TOTAL WEEKS WORKED          ***
***********************************;

if starw>0 and stopw>0 then do;
   do i=(starw) to (stopw);
      jobwks=uid;
      hourwk=hours;
      if r0mil=1 then do;
         jobwks=6;
         hourwk=0;
      end;      
   end;
   do i=893 to 1641;
         if jobwks>9700 and hourwk=0 then hourwk=-3;
   end;
end;
end;

*******************************************************************
*** translate the continuous week# into year/week combination
    for start/stop dates of jobs and job gaps ***
*******************************************************************;

array accwk  starw01-starw09 stopw01-stopw09
             bgap01_01-bgap01_13 egap01_01-egap01_13
             bgap02_01-bgap02_09 egap02_01-egap02_09
             bgap03_01-bgap03_04 egap03_01-egap03_04
             bgap04_01-bgap04_02 egap04_01-egap04_02;
array wkinyr stawk01-stawk09  stowk01-stowk09
             b1gawk1-b1gawk13 e1gawk1-e1gawk13
             b2gawk1-b2gawk9  e2gawk1-e2gawk9
             b3gawk1-b3gawk4  e3gawk1-e3gawk4
             b4gawk1-b4gawk2  e4gawk1-e4gawk2;
array yr     stayr01-stayr09  stoyr01-stoyr09
             b1gayr1-b1gayr13 e1gayr1-e1gayr13
             b2gayr1-b2gayr9  e2gayr1-e2gayr9
             b3gayr1-b3gayr4  e3gayr1-e3gayr4
             b4gayr1-b4gayr2  e4gayr1-e4gayr2;

do over accwk;   
   wkinyr=-4; yr=-4;
   if  731 le accwk le  783 then do; yr=1994; wkinyr=accwk-730;  end;  
   if  784 le accwk le  835 then do; yr=1995; wkinyr=accwk-783;  end;
   if  836 le accwk le  887 then do; yr=1996; wkinyr=accwk-835;  end;
   if  888 le accwk le  939 then do; yr=1997; wkinyr=accwk-887;  end;  
   if  940 le accwk le  991 then do; yr=1998; wkinyr=accwk-939;  end;
   if  992 le accwk le 1043 then do; yr=1999; wkinyr=accwk-991;  end;    
   if 1044 le accwk le 1096 then do; yr=2000; wkinyr=accwk-1043; end;  
   if 1097 le accwk le 1148 then do; yr=2001; wkinyr=accwk-1096; end;     
   if 1149 le accwk le 1200 then do; yr=2002; wkinyr=accwk-1148; end;  
   if 1201 le accwk le 1252 then do; yr=2003; wkinyr=accwk-1200; end;
   if 1253 le accwk le 1304 then do; yr=2004; wkinyr=accwk-1252; end;  
   if 1305 le accwk le 1357 then do; yr=2005; wkinyr=accwk-1304; end;
   if 1358 le accwk le 1409 then do; yr=2006; wkinyr=accwk-1357; end;
   if 1410 le accwk le 1461 then do; yr=2007; wkinyr=accwk-1409; end;
   if 1462 le accwk le 1513 then do; yr=2008; wkinyr=accwk-1461; end;
   if 1514 le accwk le 1565 then do; yr=2009; wkinyr=accwk-1513; end;
   if 1566 le accwk le 1617 then do; yr=2010; wkinyr=accwk-1565; end;
   if 1618 le accwk le 1641 then do; yr=2011; wkinyr=accwk-1617; end;
end;

*** invalid answers for all job start/stop dates;
array stawk    stawk01-stawk09;
array stowk    stowk01-stowk09;
array stayr    stayr01-stayr09;
array stoyr    stoyr01-stoyr09;

do over stawk;
  if smof=1 then stawk=-3;    
  if emof=1 then stowk=-3;
  if staryrf=1 then do; stayr=-3; stawk=-3; end;        
  if stopyrf=1 then do; stoyr=-3; stowk=-3; end;
end;

*** Remove gaps1-8 on jobs1-5;
   array bgap1     &bgap_01;
   array bgap2     &bgap_02;
   array bgap3     &bgap_03;
   array bgap4     &bgap_04;
   array bgap5     &bgap_05;
   array bgap6     &bgap_06;
   array bgap7     &bgap_07;
   array bgap8     &bgap_08;
   array bgap9     &bgap_09;
   array bgap10    &bgap_10;
   array bgap11    &bgap_11;
   array bgap12    &bgap_12;
   array bgap13    &bgap_13;

   array egap1     &egap_01;
   array egap2     &egap_02;
   array egap3     &egap_03;
   array egap4     &egap_04;
   array egap5     &egap_05;
   array egap6     &egap_06;
   array egap7     &egap_07;
   array egap8     &egap_08;
   array egap9     &egap_09;
   array egap10    &egap_10;
   array egap11    &egap_11;
   array egap12    &egap_12;
   array egap13    &egap_13;

   array bgfl1     &bgfl_01;   
   array egfl1     &egfl_01;
   array bgfl2     &bgfl_02;   
   array egfl2     &egfl_02;
   array bgfl3     &bgfl_03;   
   array egfl3     &egfl_03;
   array bgfl4     &bgfl_04;   
   array egfl4     &egfl_04;
   array bgfl5     &bgfl_05;   
   array egfl5     &egfl_05;
   array bgfl6     &bgfl_06;   
   array egfl6     &egfl_06;
   array bgfl7     &bgfl_07;
   array egfl7     &egfl_07;
   array bgfl8     &bgfl_08;   
   array egfl8     &egfl_08;
   array bgfl9     &bgfl_09;
   array egfl9     &egfl_09;
   array bgfl10    &bgfl_10;   
   array egfl10    &egfl_10;
   array bgfl11    &bgfl_11;   
   array egfl11    &egfl_11;
   array bgfl12    &bgfl_12;   
   array egfl12    &egfl_12;
   array bgfl13    &bgfl_13;   
   array egfl13    &egfl_13;

   array E10371    &E10370001;
   array E10372    &E10370002;
   array E10373    &E10370003;
   array E10374    &E10370004;
   array E10375    &E10370005;
   array E10376    &E10370006;
   array E10377    &E10370007;
   array E10378    &E10370008;
   array E10379    &E10370009;
   array E103710   &E10370010;
   array E103711   &E10370011;
   array E103712   &E10370012;
   array E103713   &E10370013;

   array E10541    &E10540001;
   array E10542    &E10540002;
   *array E10543    &E10540003;

   array blook1    blook1_1  blook2_1  blook3_1  blook4_1  E05 E06 E07 E08 E09;
   array blook2    blook1_2  blook2_2  blook3_2  blook4_2  E05 E06 E07 E08 E09;
   array blook3    blook1_3  blook2_3  blook3_3  E04       E05 E06 E07 E08 E09;
   array blook4    blook1_4  blook2_4  blook3_4  E04       E05 E06 E07 E08 E09;
   array blook5    blook1_5  blook2_5  E03       E04       E05 E06 E07 E08 E09;
   array blook6    blook1_6  blook2_6  E03       E04       E05 E06 E07 E08 E09;   
   array blook7    blook1_7  blook2_7  E03       E04       E05 E06 E07 E08 E09;
   array blook8    blook1_8  blook2_8  E03       E04       E05 E06 E07 E08 E09;
   array blook9    blook1_9  blook2_9  E03       E04       E05 E06 E07 E08 E09;
   array blook10   blook1_10 E02       E03       E04       E05 E06 E07 E08 E09;
   array blook11   blook1_11 E02       E03       E04       E05 E06 E07 E08 E09;
   array blook12   blook1_12 E02       E03       E04       E05 E06 E07 E08 E09;
   array blook13   blook1_13 E02       E03       E04       E05 E06 E07 E08 E09;

   array elook1    elook1_1  elook2_1  elook3_1  elook4_1  E05 E06 E07 E08 E09;
   array elook2    elook1_2  elook2_2  elook3_2  elook4_2  E05 E06 E07 E08 E09;
   array elook3    elook1_3  elook2_3  elook3_3  E04       E05 E06 E07 E08 E09;
   array elook4    elook1_4  elook2_4  elook3_4  E04       E05 E06 E07 E08 E09;
   array elook5    elook1_5  elook2_5  E03       E04       E05 E06 E07 E08 E09;
   array elook6    elook1_6  elook2_6  E03       E04       E05 E06 E07 E08 E09;   
   array elook7    elook1_7  elook2_7  E03       E04       E05 E06 E07 E08 E09;
   array elook8    elook1_8  elook2_8  E03       E04       E05 E06 E07 E08 E09;
   array elook9    elook1_9  elook2_9  E03       E04       E05 E06 E07 E08 E09;
   array elook10   elook1_10 E02       E03       E04       E05 E06 E07 E08 E09;
   array elook11   elook1_11 E02       E03       E04       E05 E06 E07 E08 E09;
   array elook12   elook1_12 E02       E03       E04       E05 E06 E07 E08 E09;
   array elook13   elook1_13 E02       E03       E04       E05 E06 E07 E08 E09;
    
   array E1059381  &E10593801;
   array E1059382  &E10593802;
   array E1059383  &E10593803;
   array E1059384  &E10593804;
   array E1059385  &E10593805;
   array E1059386  &E10593806;
   array E1059387  &E10593807;
   array E1059388  &E10593808;
   array E1059389  &E10593809;
   array E10593810 &E10593810;
   array E10593811 &E10593811;

   array E105951   &E10595001;
   array E105952   &E10595002;
   array E105953   &E10595003;
   array E105954   &E10595004;
   array E1059510  &E10595010;

%macro codegaps;
do over bgap&g.;
**create begin and end weeks looking;
   if E1054&g > 0 then do;
         blook&g.=floor(bgap&g.+((((egap&g.-bgap&g.)+1)-E1054&g.)/2));
         elook&g.=floor(egap&g.-((((egap&g.-bgap&g.)+1)-E1054&g.)/2));
      end;  
   if E10595&g > 0 then do;
         blook&g.=floor(bgap&g.+((((egap&g.-bgap&g.)+1)-E10595&g.)/2));
         elook&g.=floor(egap&g.-((((egap&g.-bgap&g.)+1)-E10595&g.)/2));
      end;  

**code weeks for gaps;            
   if egap&g.>=bgap&g.>0 then do;
      do i=(bgap&g.) to (egap&g.);
         jobwks=0;
         hourwk=0;
         if e1037&g.=3 then jobwks=4;
         if e1037&g in (1,2,-1,-2,-3) then jobwks=5;
         if e105938&g.=3 then jobwks=4;
         if e105938&g in (1,2,-1,-2,-3) then jobwks=5;
      end;        
   end;
   if elook&g.>=blook&g.>0 then do;
      do i=(blook&g.) to (elook&g.);
        jobwks=4;
      end;
   end;
      
   ** beginning gap date bad;
   if bgfl&g.=1 and egap&g.>0 and starw>0 then do;
      do i=(starw) to (egap&g.);
         jobwks=3;
         hourwk=-6;         
      end;
   end;
 
 ** ending gap date bad;
   if bgap&g.>0 & egfl&g.=1 and stopw>0 then do;
      do i=(bgap&g.) to (stopw);
         jobwks=3;
         hourwk=-6;         
      end;
   end;
 
** both gap dates bad;
   if bgfl&g.=1 & egfl&g.=1 and starw>0 and stopw>0 then do;
      do i=(starw) to (stopw);
         jobwks=3;
         hourwk=-6;        
      end;
   end;  
end;
%mend codegaps;

%let g=1; %codegaps
%let g=2; %codegaps
%let g=3; %codegaps
%let g=4; %codegaps
%let g=5; %codegaps
%let g=6; %codegaps  
%let g=7; %codegaps
%let g=8; %codegaps
%let g=9; %codegaps  
%let g=10; %codegaps
%let g=11; %codegaps
%let g=12; %codegaps
%let g=13; %codegaps

***bad start/stop;
do over starf;
    if starf=1 then do;
           do i=(starw) to min(stopw,begwk,(bgap1-1));
              jobwks=-3;
              hourwk=-3;
           end;
    end;
    if stopf=1 then do;
           do i=max(starw,endwk,(bgap1-1)) to (stopw);
          jobwks=-3;
          hourwk=-3;
           end;
    end;
end;

array alljobs (i) _1-_892 wks893-wks1641;
array dual2   (i) _1-_892 dl2_893-dl2_1641;
array dual3   (i) _1-_892 dl3_893-dl3_1641;
array dual4   (i) _1-_892 dl4_893-dl4_1641;
array dual5   (i) _1-_892 dl5_893-dl5_1641;
array dual6   (i) _1-_892 dl6_893-dl6_1641;
array dual7   (i) _1-_892 dl7_893-dl7_1641;
array dual8   (i) _1-_892 dl8_893-dl8_1641;

do i=rd0wk to (r0int-1);
    alljobs=job1wks;
end;

%macro dual;
do i=rd0wk to (r0int-1);
   if job&L.wks>999 and alljobs>999 and dual8<1000 and dual7>999 and dual6>999 and dual5>999
                    and dual4>999 and dual3>999 and dual2>999 then dual8=job&L.wks;
   if job&L.wks>999 and alljobs>999 and dual7<1000 and dual6>999 and dual5>999 and dual4>999
                    and dual3>999 and dual2>999 then dual7=job&L.wks;
   if job&L.wks>999 and alljobs>999 and dual6<1000 and dual5>999 and dual4>999 and dual3>999
                    and dual2>999 then dual6=job&L.wks;
   if job&L.wks>999 and alljobs>999 and dual5<1000 and dual4>999 and dual3>999 and dual2>999
                    then dual5=job&L.wks;
   if job&L.wks>999 and alljobs>999 and dual4<1000 and dual3>999 and dual2>999
                    then dual4=job&L.wks;
   if job&L.wks>999 and alljobs>999 and dual3<1000 and dual2>999 then dual3=job&L.wks;
   if job&L.wks>999 and alljobs>999 and dual2<1000 then dual2=job&L.wks;
   if job&L.wks>999 and alljobs<1000 then alljobs=job&L.wks;
   if 0<job&L.wks<1000 and alljobs=0 then alljobs=job&L.wks;
   if job&L.wks=-3 and alljobs<1000 then alljobs=-3;
end;
%mend dual;

%let L=2; %dual
%let L=3; %dual
%let L=4; %dual
%let L=5; %dual
%let L=6; %dual
%let L=7; %dual
%let L=8; %dual
%let L=9; %dual

run;

proc means n mean min max data=emp_array;
title2 'emp_array_other';
var pubid wks893-wks1641
    stawk01-stawk09  stowk01-stowk09
    b1gawk1-b1gawk13 e1gawk1-e1gawk13
    b2gawk1-b2gawk9  e2gawk1-e2gawk9
    b3gawk1-b3gawk4  e3gawk1-e3gawk4
    b4gawk1-b4gawk2  e4gawk1-e4gawk2
    stayr01-stayr09  stoyr01-stoyr09
    b1gayr1-b1gayr13 e1gayr1-e1gayr13
    b2gayr1-b2gayr9  e2gayr1-e2gayr9
    b3gayr1-b3gayr4  e3gayr1-e3gayr4
    b4gayr1-b4gayr2  b4gayr1-b4gayr2     
    dl2_:
    dl3_:
    dl4_:
    dl5_:
    dl6_:
    dl7_:
    dl8_:
;   
run;

data emp_array_hrs;
set emp_array(keep=pubid hr1_893-hr1_1641 &r0uid r0int rd0wk
                          hr2_893-hr2_1641 hr3_893-hr3_1641 hr4_893-hr4_1641
                          hr5_893-hr5_1641 hr6_893-hr6_1641 hr7_893-hr7_1641
                          hr8_893-hr8_1641 hr9_893-hr9_1641
                          starw01-starw09 stopw01-stopw09
                          hours01-hours09 starf_1-starf_9 stopf_1-stopf_9);   
                
array hourwk1 (i) _1-_892 hr1_893-hr1_1641;
array hourwk2 (i) _1-_892 hr2_893-hr2_1641;
array hourwk3 (i) _1-_892 hr3_893-hr3_1641;
array hourwk4 (i) _1-_892 hr4_893-hr4_1641;
array hourwk5 (i) _1-_892 hr5_893-hr5_1641;
array hourwk6 (i) _1-_892 hr6_893-hr6_1641;
array hourwk7 (i) _1-_892 hr7_893-hr7_1641;
array hourwk8 (i) _1-_892 hr8_893-hr8_1641;
array hourwk9 (i) _1-_892 hr9_893-hr9_1641;

array allhrs  (i) _1-_892 hr893-hr1641;

*******************************************************
**      Overlay multiple hours over work weeks       **
*******************************************************;

do i=rd0wk to r0int-1;
   allhrs=-4;

   if hourwk1=-1 or hourwk1=-2 or hourwk1=-6 then hourwk1=-3;
   if hourwk1 ne 0 then allhrs=hourwk1;  

   if hourwk2 in (-6,-3,-2,-1) then allhrs=-3;
   if hourwk2>0 and allhrs>-3  then allhrs=allhrs+hourwk2;
   if hourwk2>0 and allhrs=-4  then allhrs=hourwk2;
   
   if hourwk3 in (-6,-3,-2,-1) then allhrs=-3;
   if hourwk3>0 and allhrs>-3  then allhrs=allhrs+hourwk3;
   if hourwk3>0 and allhrs=-4  then allhrs=hourwk3;
   
   if hourwk4 in (-6,-3,-2,-1) then allhrs=-3;
   if hourwk4>0 and allhrs>-3  then allhrs=allhrs+hourwk4;
   if hourwk4>0 and allhrs=-4  then allhrs=hourwk4;
   
   if hourwk5 in (-6,-3,-2,-1) then allhrs=-3;
   if hourwk5>0 and allhrs>-3  then allhrs=allhrs+hourwk5;
   if hourwk5>0 and allhrs=-4  then allhrs=hourwk5;
   
   if hourwk6 in (-6,-3,-2,-1) then allhrs=-3;
   if hourwk6>0 and allhrs>-3  then allhrs=allhrs+hourwk6;
   if hourwk6>0 and allhrs=-4  then allhrs=hourwk6;
   
   if hourwk7 in (-6,-3,-2,-1) then allhrs=-3;
   if hourwk7>0 and allhrs>-3  then allhrs=allhrs+hourwk7;
   if hourwk7>0 and allhrs=-4  then allhrs=hourwk7;

   if hourwk8 in (-6,-3,-2,-1) then allhrs=-3;
   if hourwk8>0 and allhrs>-3  then allhrs=allhrs+hourwk8;
   if hourwk8>0 and allhrs=-4  then allhrs=hourwk8;

   if hourwk9 in (-6,-3,-2,-1) then allhrs=-3;
   if hourwk9>0 and allhrs>-3  then allhrs=allhrs+hourwk9;
   if hourwk9>0 and allhrs=-4  then allhrs=hourwk9;   
 end;  

** Convert all codes after the current interview week to -5;
do i=r0int to 1641;
   allhrs=-5;
end;
** Convert all codes from week1 till the week before DLI to -4;
do i=893 to rd0wk-1;    
   allhrs=-4;
end;
 
proc means n mean min max data=emp_array_hrs;
var pubid hr893-hr1641;
run;

data emp_btw;
merge two emp_int(keep=pubid r0int)
      emp_week(keep=pubid back)
      emp_countweeks(keep=pubid rd0wk)
      emp_array(keep=pubid wks893-wks1641);
by pubid; if r0int>-5;  

array alljobs (*)     _1-_892 wks893-wks1641; * weekly job status array;
array aftjobs (*)     _1-_892 wks894-wks1642; * weekly job status array, forward one week;
array E119000 (9)     &E119000; *CHK TTL # WKS BJGAP 2008;
array E119200 (9)     &E119200; *# WKS LK WRK/LYFF S-EMP BJOB GAP 2008;
array gp_lthC (9)     gp_lthC1-gp_lthC9; * CAPI - btw job gap length;
array sr_lthC (9)     sr_lthC1-sr_lthC9; * CAPI - btw job search length;
array gp_lth  (9)     gp_lth1-gp_lth9;   * EVENT - btw job gap length;
array sr_lth  (9)     sr_lth1-sr_lth9;   * EVENT - btw job search length;
array gapb    (9)     gapb1-gapb9;       * start week of a gap;
array gape    (9)     gape1-gape9;       * stop week of a gap;
array olf_lth (9)     olf_lth1-olf_lth9; * period of btw job gap out of labor force;
array halfolf (9)     halfolf1-halfolf9; * half of olf_lth;
array unempb  (9)     unempb1-unempb9;   * start week of unemployment period (search) in btw job gap;
array unempe  (9)     unempe1-unempe9;   * stop week of unemployment period (search) in btw job gap;
array agp_lth (9)     agp_lth1-agp_lth9; * event gaps adjusted for zero gaps in CAPI;
array CPgpdf  (9)     CPgpdf1-CPgpdf9; * gap length difference capi and adjusted event;

do j=1 to 9;
    if E119000(j) ne . then gp_lthC(j)=E119000(j);
    if E119200(j) ne . then sr_lthC(j)=E119200(j);
end;

*** Initialize start and stop weeks of between job gaps;
do j=1 to dim(gapb);
    gapb(j)=0;
    gape(j)=0;    
end;

*** Define between job gaps from event history;
do i=rd0wk;
   if alljobs(i)=0 then gapb1=i;    
end;

do i=rd0wk to r0int-1;
   if alljobs(i) ne 0 and aftjobs(i)=0 and gapb1=0 then gapb1=i+1;   
   if alljobs(i)=0 and aftjobs(i) ne 0 and gape1=0 then gape1=i;
end;

do j=1 to dim(gapb);
   if gapb(j)>0 then do;
      do i=gapb(j)+1 to r0int-1;       
         if alljobs(i) ne 0 and aftjobs(i)=0 and gapb(j+1)=0 then gapb(j+1)=i+1;
      end;
   end;
end;

do j=1 to dim(gape);
   if gape(j)>0 and gapb(j+1)>0 then do;
      do i=gape(j)+1 to r0int-1;       
         if alljobs(i)=0 and aftjobs(i) ne 0 and gape(j+1)=0 then gape(j+1)=i;         
      end;
   end;
end;

* Find the last bjgap start this round, and if gapend missing set to r0int-1;
bjlast=max(gapb1,gapb2,gapb3,gapb4,gapb5,gapb6,gapb7,gapb8,gapb9);

do j=1 to dim(gapb);
    if bjlast>0 and gapb(j)=bjlast and gape(j)=0 then gape(j)=r0int-1;
end;

drop _1-_892;

*Incorporate search activity so that unemployed vs OLF can be determined for each bjgap;
*Only need to do this for cases with job search activity;
*Bjgaps=zero weeks (gp_lthC=0) are not on event history (gp_lth);
*Bjgaps=one week (gp_lthC=1) may not be on event history (gp_lth);
*Find these cases (_cpzr>0,_cpzr1>0) and adjust gp_lth loops (agp_lth=gp_lthC);
*Select sr_lthC as sr_lth for each gp_lth;

search=0;
do j=1 to dim(gapb);
   if gapb(j)>0 and gape(j)>0 and (gape(j)>=gapb(j)) then do;
        gp_lth(j)=((gape(j)-gapb(j))+1);
        agp_lth(j)=0;
        if sr_lthC(j)>0 then search=search+sr_lthC(j);
        if sr_lthC(j) in (-1,-2) then search=sr_lthC(j);
   end;
end;

if search not in (.) then do;
    _cpzr=0;
    _cpzr1=0;
end;

do j=1 to dim(gapb);
  if gp_lthC(j)=0 and gp_lthC(j+1)>0 then _cpzr=_cpzr+1;
  if gp_lthC(j)=0 and gp_lthC(j+1)=0 and gp_lthC(j+2)>0 then _cpzr=_cpzr+1;
  if gp_lthC(j)=1 and gp_lth(j) ne gp_lthC(j) and gp_lthC(j+1)>1 then _cpzr1=_cpzr1+1;  
  if gp_lthC(j)=1 and gp_lth(j) ne gp_lthC(j) and
     gp_lthC(j+1)=0 and gp_lthC(j+2)>1 then _cpzr1=_cpzr1+1;
end;

** Get sr_lth from sr_lthC;
do j=1 to dim(gapb);  
   if _cpzr=0 and _cpzr1=0 and gp_lth(j)>0 then do;
      if sr_lthC(j) ge 0 then sr_lth(j)=sr_lthC(j); agp_lth(j)=gp_lth(j);
   end;
   if _cpzr=1 and _cpzr1=0 and -2 le gp_lth(j)-gp_lthC(j) le 2 then do;
      if sr_lthC(j) ge 0 then sr_lth(j)=sr_lthC(j); agp_lth(j)=gp_lth(j);
   end;
   if _cpzr=0 and _cpzr1=1 and -2 le gp_lth(j)-gp_lthC(j) le 2 then do;
      if sr_lthC(j) ge 0 then sr_lth(j)=sr_lthC(j); agp_lth(j)=gp_lth(j);
   end;  
end;

if _cpzr=1 and gp_lthC1=0 and gp_lthC2>0 and gp_lth2 ne gp_lthC2
    and -2 le gp_lth1-gp_lthC2 le 2 then do;
    agp_lth1=0;
    if sr_lthC2 ge 0 then sr_lth1=sr_lthC2; agp_lth2=gp_lth1;
    if sr_lthC3 ge 0 then sr_lth2=sr_lthC3; agp_lth3=gp_lth2;
    if sr_lthC4 ge 0 then sr_lth3=sr_lthC4; agp_lth4=gp_lth3;
    if sr_lthC5 ge 0 then sr_lth4=sr_lthC5; agp_lth5=gp_lth4;
end;
 
if _cpzr=1 and gp_lthC2=0 and -2 le gp_lth2-gp_lthC3 le 2 then do;
    if sr_lthC1 ge 0 then sr_lth1=sr_lthC1; agp_lth1=gp_lth1; agp_lth2=0;
    if sr_lthC3 ge 0 then sr_lth2=sr_lthC3; agp_lth3=gp_lth2;
    if sr_lthC4 ge 0 then sr_lth3=sr_lthC4; agp_lth4=gp_lth3;
end;

if _cpzr=1 and gp_lthC3=0 and -2 le gp_lth3-gp_lthC4 le 2 then do;
    if sr_lthC1 ge 0 then sr_lth1=sr_lthC1; agp_lth1=gp_lth1;
    if sr_lthC2 ge 0 then sr_lth2=sr_lthC2; agp_lth2=gp_lth2;agp_lth3=0;
    if sr_lthC3 ge 0 then sr_lth3=sr_lthC4; agp_lth4=gp_lth3;
end;

if _cpzr=1 and gp_lthC1=0 and gp_lthC2=0 and -2 le gp_lth1-gp_lthC3 le 2 then do;
    agp_lth1=0;
    agp_lth2=0;
    if sr_lthC3 ge 0 then sr_lth1=sr_lthC3; agp_lth3=gp_lth1;     
end;
    
if _cpzr=2 and gp_lthC1=0 and -2 le gp_lth1-gp_lthC2 le 2
   and gp_lthC4=0 and -2 le gp_lth3-gp_lthC5 le 2 then do;
    agp_lth1=0;
    if sr_lthC2 ge 0 then sr_lth1=sr_lthC2; agp_lth2=gp_lth1;
    if sr_lthC3 ge 0 then sr_lth2=sr_lthC3; agp_lth3=gp_lth2; agp_lth4=0;
    if sr_lthC5 ge 0 then sr_lth3=sr_lthC5; agp_lth5=gp_lth3;
end;
 
if _cpzr=2 and gp_lthC1=0 and -2 le gp_lth1-gp_lthC2 le 2
   and gp_lthC3=0 then do;       
    agp_lth1=0;
    if sr_lthC2 ge 0 then sr_lth1=sr_lthC2; agp_lth2=gp_lth1; agp_lth3=0;
    if sr_lthC4 ge 0 then sr_lth2=sr_lthC4; agp_lth4=gp_lth2;
end;
 
if _cpzr=2 and gp_lthC2=0 and -2 le gp_lth2-gp_lthC3 le 2
   and -2 le gp_lth3-gp_lthC4 le 2 then do;       
    if sr_lthC1 ge 0 then sr_lth1=sr_lthC1; agp_lth1=gp_lth1; agp_lth2=0;
    if sr_lthC3 ge 0 then sr_lth2=sr_lthC3; agp_lth3=gp_lth2;
    if sr_lthC4 ge 0 then sr_lth3=sr_lthC4; agp_lth4=gp_lth3;
    if sr_lthC5 ge 0 then sr_lth4=sr_lthC5; agp_lth5=gp_lth4;
    if sr_lthC6 ge 0 then sr_lth5=sr_lthC6; agp_lth6=gp_lth5;
end;

if _cpzr=2 and gp_lthC3=0 and -2 le gp_lth3-gp_lthC4 le 2
   and gp_lthC5=0 and -2 le gp_lth4-gp_lthC6 le 2 then do;
    if sr_lthC1 ge 0 then sr_lth1=sr_lthC1; agp_lth1=gp_lth1;
    if sr_lthC2 ge 0 then sr_lth2=sr_lthC2; agp_lth2=gp_lth2; agp_lth3=0;
    if sr_lthC4 ge 0 then sr_lth3=sr_lthC4; agp_lth4=gp_lth3; agp_lth5=0;
    if sr_lthC6 ge 0 then sr_lth4=sr_lthC6; agp_lth6=gp_lth4;
    if sr_lthC7 ge 0 then sr_lth5=sr_lthC7; agp_lth7=gp_lth5;
    if sr_lthC8 ge 0 then sr_lth6=sr_lthC8; agp_lth8=gp_lth6;
end;
 
if _cpzr=3 and gp_lthC1=0 and gp_lthC3=0 and gp_lthC4=0 then do;
    if sr_lthC2 ge 0 then sr_lth1=sr_lthC2; agp_lth2=gp_lth1; agp_lth3=0; agp_lth4=0;
    if sr_lthC5 ge 0 then sr_lth2=sr_lthC5; agp_lth5=gp_lth2;                                             
    if sr_lthC6 ge 0 then sr_lth3=sr_lthC6; agp_lth6=gp_lth3;    
end;

if _cpzr1=1 and gp_lthC1=1 and gp_lth2 ne gp_lthC2 and -2 le gp_lth1-gp_lthC2 le 2 then do;
    agp_lth1=0;
    if sr_lthC2 ge 0 then sr_lth1=sr_lthC2; agp_lth2=gp_lth1;
    if sr_lthC3 ge 0 then sr_lth2=sr_lthC3; agp_lth3=gp_lth2;
    if sr_lthC4 ge 0 then sr_lth3=sr_lthC4; agp_lth4=gp_lth3;
    if sr_lthC5 ge 0 then sr_lth4=sr_lthC5; agp_lth5=gp_lth4;
end;

if _cpzr=0 and _cpzr1 in (1,2) and gp_lthC2=1 and -2 le gp_lth2-gp_lthC3 le 2 then do;
    if sr_lthC1 ge 0 then sr_lth1=sr_lthC1; agp_lth1=gp_lth1; agp_lth2=0;
    if sr_lthC3 ge 0 then sr_lth2=sr_lthC3; agp_lth3=gp_lth2;
    if sr_lthC4 ge 0 then sr_lth3=sr_lthC4; agp_lth4=gp_lth3;
    if sr_lthC5 ge 0 then sr_lth4=sr_lthC5; agp_lth5=gp_lth4;
    if sr_lthC6 ge 0 then sr_lth5=sr_lthC6; agp_lth6=gp_lth5;
end;

if _cpzr=0 and _cpzr1 in (1,2) and gp_lthC4=1 and -2 le gp_lth4-gp_lthC5 le 2 then do;
    if sr_lthC1 ge 0 then sr_lth1=sr_lthC1; agp_lth1=gp_lth1;     
    if sr_lthC2 ge 0 then sr_lth2=sr_lthC2; agp_lth2=gp_lth2;                                       
    if sr_lthC3 ge 0 then sr_lth3=sr_lthC3; agp_lth3=gp_lth3; agp_lth4=0;
    if sr_lthC5 ge 0 then sr_lth4=sr_lthC5; agp_lth5=gp_lth4;
    if sr_lthC6 ge 0 then sr_lth5=sr_lthC6; agp_lth6=gp_lth5;
end;

if _cpzr=1 and _cpzr1=1 and gp_lthC1=1 and gp_lthC2=0
   and -2 le gp_lth1-gp_lthC3 le 2 then do;
    agp_lth1=0;     
    agp_lth2=0;
    if sr_lthC3 ge 0 then sr_lth1=sr_lthC3; agp_lth3=gp_lth1;    
end;

if _cpzr=1 and _cpzr1=1 and gp_lthC3=1 and gp_lthC4=0
   and -2 le gp_lth3-gp_lthC5 le 2 then do;
    agp_lth1=gp_lth1;
    agp_lth2=gp_lth2;
    agp_lth3=0;     
    agp_lth4=0;
    if sr_lthC5 ge 0 then sr_lth3=sr_lthC5; agp_lth5=gp_lth3;    
end;

*** Code weeks of between job gaps as
    0=No Information,
    2=Not working (not sure whether unemployed or out of labor force),
    4=unemployed,
    5=out of labor force;
   
do j=1 to dim(gapb);      
   if gapb(j)>0 and gape(j)>0 and (gape(j)>=gapb(j)) then do;   
            
      ** Code all weeks in the gap as 5 (OLF) by default;
      do i=gapb(j) to gape(j);
         alljobs(i)=5;
      end;

      ** R did not answer search questions, code all weeks in the gap as 2;        
      if gp_lthC(j) in (-4,-3) or sr_lthC(j) in (-1,-2) then do;
         do i=gapb(j) to gape(j);
            alljobs(i)=2;
         end;
      end;

      ** Constrain search length by the gap length;      
      if (0<gp_lth(j)<sr_lth(j)) then sr_lth(j)=gp_lth(j);

      ** Compute the start stop weeks of the btw job unemployment period and length
         (& half length) of that period;      
      if gp_lth(j)>=sr_lth(j)>0 then do;
         olf_lth(j)=gp_lth(j)-sr_lth(j);
         halfolf(j)=((gp_lth(j)-sr_lth(j))/2);
         unempb(j)=floor(gapb(j)+halfolf(j));    
         unempe(j)=floor(gape(j)-halfolf(j));    
      end;

      ** Set unemployment in the btw job gaps;
      if unempe(j)>=unempb(j)>0 then do;
         do i=unempb(j) to unempe(j);
            alljobs(i)=4;
         end;
      end;    
   end;   
end;

** Convert all codes after current interview week to -5;
do i=(r0int) to (1641);
    alljobs(i)=-5;
end;

** Convert all codes before DLI to -4;
do i=893 to (rd0wk-1);    
    alljobs(i)=-4;
end;

** Convert all codes that are 0 to 2;
do i=893 to 1641;
    if alljobs(i)=0 then alljobs(i)=2;
end;

** Convert all codes that are -3 to 0;
do i=893 to 1641;
    if alljobs(i)=-3 then alljobs(i)=0;
end;

** Check gap adjustment;
do j=1 to dim(gapb);  
   if gp_lthC(j) ge 0 and agp_lth(j) ge 0 then CPgpdf(j)=agp_lth(j)-gp_lthC(j);  
end;
run;