Core Employment Variables, Linking to Past Rounds

National Longitudinal Survey of Youth - 1997 Cohort

Core Employment Variables, Linking to Past Rounds

SAS Code for Variable Creation

data two;
set r14.current
(keep=pubid
      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
      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
      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
      YEMP_9899M_01 YEMP_9899M_02 YEMP_9899M_03 YEMP_9899M_04 YEMP_9899M_05 YEMP_9899M_06 YEMP_9899M_07 YEMP_9899M_08);

CALL SYMPUT ('R0MIL ','YEMP_MILFLAG_01-YEMP_MILFLAG_09 ');
CALL SYMPUT ('R0SEL ','YEMP_SELFEMP_01-YEMP_SELFEMP_09 ');
CALL SYMPUT ('R0UID ','YEMP_UID_01-YEMP_UID_09 ');
CALL SYMPUT ('E9899M ','YEMP_9899M_01-YEMP_9899M_08 E09 ');

proc means data=two;

data one; set r14.prior;
CALL SYMPUT ('R1COM ','CV_HRLY_COMPENSATION_1997_01-CV_HRLY_COMPENSATION_1997_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1PAY ','CV_HRLY_PAY_1997_01-CV_HRLY_PAY_1997_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1STAD ','YEMP_STARTDATE_1997_D_01-YEMP_STARTDATE_1997_D_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1STAM ','YEMP_STARTDATE_1997_M_01-YEMP_STARTDATE_1997_M_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1STAY ','YEMP_STARTDATE_1997_Y_01-YEMP_STARTDATE_1997_Y_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1STOD ','YEMP_STOPDATE_1997_D_01-YEMP_STOPDATE_1997_D_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1STOM ','YEMP_STOPDATE_1997_M_01-YEMP_STOPDATE_1997_M_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1STOY ','YEMP_STOPDATE_1997_Y_01-YEMP_STOPDATE_1997_Y_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1TEN ','CV_WKSWK_JOB_DLI_1997_01-CV_WKSWK_JOB_DLI_1997_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R1UID ','YEMP_UID_1997_01-YEMP_UID_1997_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R2COM ','CV_HRLY_COMPENSATION_1998_01-CV_HRLY_COMPENSATION_1998_09 E10 E11 ');
CALL SYMPUT ('R2MIL ','YEMP_MILFLAG_1998_01-YEMP_MILFLAG_1998_09 E10 E11 ');
CALL SYMPUT ('R2PAY ','CV_HRLY_PAY_1998_01-CV_HRLY_PAY_1998_09 E10 E11 ');
CALL SYMPUT ('R2STAD ','YEMP_STARTDATE_1998_D_01-YEMP_STARTDATE_1998_D_09 E10 E11 ');
CALL SYMPUT ('R2STAM ','YEMP_STARTDATE_1998_M_01-YEMP_STARTDATE_1998_M_09 E10 E11 ');
CALL SYMPUT ('R2STAY ','YEMP_STARTDATE_1998_Y_01-YEMP_STARTDATE_1998_Y_09 E10 E11 ');
CALL SYMPUT ('R2STOD ','YEMP_STOPDATE_1998_D_01-YEMP_STOPDATE_1998_D_09 E10 E11 ');
CALL SYMPUT ('R2STOM ','YEMP_STOPDATE_1998_M_01-YEMP_STOPDATE_1998_M_09 E10 E11 ');
CALL SYMPUT ('R2STOY ','YEMP_STOPDATE_1998_Y_01-YEMP_STOPDATE_1998_Y_09 E10 E11 ');
CALL SYMPUT ('R2TEN ','CV_WKSWK_JOB_DLI_1998_01-CV_WKSWK_JOB_DLI_1998_09 E10 E11 ');
CALL SYMPUT ('R2UID ','YEMP_UID_1998_01-YEMP_UID_1998_09 E10 E11 ');
CALL SYMPUT ('R3COM ','CV_HRLY_COMPENSATION_1999_01-CV_HRLY_COMPENSATION_1999_09 E10 E11 ');
CALL SYMPUT ('R3MIL ','YEMP_MILFLAG_1999_01-YEMP_MILFLAG_1999_09 E10 E11 ');
CALL SYMPUT ('R3PAY ','CV_HRLY_PAY_1999_01-CV_HRLY_PAY_1999_09 E10 E11 ');
CALL SYMPUT ('R3STAD ','YEMP_STARTDATE_1999_D_01-YEMP_STARTDATE_1999_D_09 E10 E11 ');
CALL SYMPUT ('R3STAM ','YEMP_STARTDATE_1999_M_01-YEMP_STARTDATE_1999_M_09 E10 E11 ');
CALL SYMPUT ('R3STAY ','YEMP_STARTDATE_1999_Y_01-YEMP_STARTDATE_1999_Y_09 E10 E11 ');
CALL SYMPUT ('R3STOD ','YEMP_STOPDATE_1999_D_01-YEMP_STOPDATE_1999_D_09 E10 E11 ');
CALL SYMPUT ('R3STOM ','YEMP_STOPDATE_1999_M_01-YEMP_STOPDATE_1999_M_09 E10 E11 ');
CALL SYMPUT ('R3STOY ','YEMP_STOPDATE_1999_Y_01-YEMP_STOPDATE_1999_Y_09 E10 E11 ');
CALL SYMPUT ('R3TEN ','CV_WKSWK_JOB_DLI_1999_01-CV_WKSWK_JOB_DLI_1999_09 E10 E11 ');
CALL SYMPUT ('R3UID ','YEMP_UID_1999_01-YEMP_UID_1999_09 E10 E11 ');
CALL SYMPUT ('R4COM ','CV_HRLY_COMPENSATION_2000_01-CV_HRLY_COMPENSATION_2000_09 E10 E11 ');
CALL SYMPUT ('R4MIL ','YEMP_MILFLAG_2000_01-YEMP_MILFLAG_2000_09 E10 E11 ');
CALL SYMPUT ('R4PAY ','CV_HRLY_PAY_2000_01-CV_HRLY_PAY_2000_09 E10 E11 ');
CALL SYMPUT ('R4SEL ','YEMP_SELFEMP_2000_01-YEMP_SELFEMP_2000_09 E10 E11 ');
CALL SYMPUT ('R4STAD ','YEMP_STARTDATE_2000_D_01-YEMP_STARTDATE_2000_D_09 E10 E11 ');
CALL SYMPUT ('R4STAM ','YEMP_STARTDATE_2000_M_01-YEMP_STARTDATE_2000_M_09 E10 E11 ');
CALL SYMPUT ('R4STAY ','YEMP_STARTDATE_2000_Y_01-YEMP_STARTDATE_2000_Y_09 E10 E11 ');
CALL SYMPUT ('R4STOD ','YEMP_STOPDATE_2000_D_01-YEMP_STOPDATE_2000_D_09 E10 E11 ');
CALL SYMPUT ('R4STOM ','YEMP_STOPDATE_2000_M_01-YEMP_STOPDATE_2000_M_09 E10 E11 ');
CALL SYMPUT ('R4STOY ','YEMP_STOPDATE_2000_Y_01-YEMP_STOPDATE_2000_Y_09 E10 E11 ');
CALL SYMPUT ('R4TEN ','CV_WKSWK_JOB_DLI_2000_01-CV_WKSWK_JOB_DLI_2000_09 E10 E11 ');
CALL SYMPUT ('R4UID ','YEMP_UID_2000_01-YEMP_UID_2000_09 E10 E11 ');
CALL SYMPUT ('R5COM ','CV_HRLY_COMPENSATION_2001_01-CV_HRLY_COMPENSATION_2001_08 E09 E10 E11 ');
CALL SYMPUT ('R5MIL ','YEMP_MILFLAG_2001_01-YEMP_MILFLAG_2001_08 E09 E10 E11 ');
CALL SYMPUT ('R5PAY ','CV_HRLY_PAY_2001_01-CV_HRLY_PAY_2001_08 E09 E10 E11 ');
CALL SYMPUT ('R5SEL ','YEMP_SELFEMP_2001_01-YEMP_SELFEMP_2001_08 E09 E10 E11 ');
CALL SYMPUT ('R5STAD ','YEMP_STARTDATE_2001_D_01-YEMP_STARTDATE_2001_D_08 E09 E10 E11 ');
CALL SYMPUT ('R5STAM ','YEMP_STARTDATE_2001_M_01-YEMP_STARTDATE_2001_M_08 E09 E10 E11 ');
CALL SYMPUT ('R5STAY ','YEMP_STARTDATE_2001_Y_01-YEMP_STARTDATE_2001_Y_08 E09 E10 E11 ');
CALL SYMPUT ('R5STOD ','YEMP_STOPDATE_2001_D_01-YEMP_STOPDATE_2001_D_08 E09 E10 E11 ');
CALL SYMPUT ('R5STOM ','YEMP_STOPDATE_2001_M_01-YEMP_STOPDATE_2001_M_08 E09 E10 E11 ');
CALL SYMPUT ('R5STOY ','YEMP_STOPDATE_2001_Y_01-YEMP_STOPDATE_2001_Y_08 E09 E10 E11 ');
CALL SYMPUT ('R5TEN ','CV_WKSWK_JOB_DLI_2001_01-CV_WKSWK_JOB_DLI_2001_08 E09 E10 E11 ');
CALL SYMPUT ('R5UID ','YEMP_UID_2001_01-YEMP_UID_2001_08 E09 E10 E11 ');
CALL SYMPUT ('R6COM ','CV_HRLY_COMPENSATION_2002_01-CV_HRLY_COMPENSATION_2002_11 ');
CALL SYMPUT ('R6MIL ','YEMP_MILFLAG_2002_01-YEMP_MILFLAG_2002_11 ');
CALL SYMPUT ('R6PAY ','CV_HRLY_PAY_2002_01-CV_HRLY_PAY_2002_11 ');
CALL SYMPUT ('R6SEL ','YEMP_SELFEMP_2002_01-YEMP_SELFEMP_2002_11 ');
CALL SYMPUT ('R6STAD ','YEMP_STARTDATE_2002_D_01-YEMP_STARTDATE_2002_D_11 ');
CALL SYMPUT ('R6STAM ','YEMP_STARTDATE_2002_M_01-YEMP_STARTDATE_2002_M_11 ');
CALL SYMPUT ('R6STAY ','YEMP_STARTDATE_2002_Y_01-YEMP_STARTDATE_2002_Y_11 ');
CALL SYMPUT ('R6STOD ','YEMP_STOPDATE_2002_D_01-YEMP_STOPDATE_2002_D_11 ');
CALL SYMPUT ('R6STOM ','YEMP_STOPDATE_2002_M_01-YEMP_STOPDATE_2002_M_11 ');
CALL SYMPUT ('R6STOY ','YEMP_STOPDATE_2002_Y_01-YEMP_STOPDATE_2002_Y_11 ');
CALL SYMPUT ('R6TEN ','CV_WKSWK_JOB_DLI_2002_01-CV_WKSWK_JOB_DLI_2002_11 ');
CALL SYMPUT ('R6UID ','YEMP_UID_2002_01-YEMP_UID_2002_11 ');
CALL SYMPUT ('R7COM ','CV_HRLY_COMPENSATION_2003_01-CV_HRLY_COMPENSATION_2003_10 E11 ');
CALL SYMPUT ('R7MIL ','YEMP_MILFLAG_2003_01-YEMP_MILFLAG_2003_10 E11 ');
CALL SYMPUT ('R7PAY ','CV_HRLY_PAY_2003_01-CV_HRLY_PAY_2003_10 E11 ');
CALL SYMPUT ('R7SEL ','YEMP_SELFEMP_2003_01-YEMP_SELFEMP_2003_10 E11 ');
CALL SYMPUT ('R7STAD ','YEMP_STARTDATE_2003_D_01-YEMP_STARTDATE_2003_D_10 E11 ');
CALL SYMPUT ('R7STAM ','YEMP_STARTDATE_2003_M_01-YEMP_STARTDATE_2003_M_10 E11 ');
CALL SYMPUT ('R7STAY ','YEMP_STARTDATE_2003_Y_01-YEMP_STARTDATE_2003_Y_10 E11 ');
CALL SYMPUT ('R7STOD ','YEMP_STOPDATE_2003_D_01-YEMP_STOPDATE_2003_D_10 E11 ');
CALL SYMPUT ('R7STOM ','YEMP_STOPDATE_2003_M_01-YEMP_STOPDATE_2003_M_10 E11 ');
CALL SYMPUT ('R7STOY ','YEMP_STOPDATE_2003_Y_01-YEMP_STOPDATE_2003_Y_10 E11 ');
CALL SYMPUT ('R7TEN ','CV_WKSWK_JOB_DLI_2003_01-CV_WKSWK_JOB_DLI_2003_10 E11 ');
CALL SYMPUT ('R7UID ','YEMP_UID_2003_01-YEMP_UID_2003_10 E11 ');
CALL SYMPUT ('R8COM ','CV_HRLY_COMPENSATION_2004_01-CV_HRLY_COMPENSATION_2004_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8MIL ','YEMP_MILFLAG_2004_01-YEMP_MILFLAG_2004_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8PAY ','CV_HRLY_PAY_2004_01-CV_HRLY_PAY_2004_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8SEL ','YEMP_SELFEMP_2004_01-YEMP_SELFEMP_2004_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8STAD ','YEMP_STARTDATE_2004_D_01-YEMP_STARTDATE_2004_D_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8STAM ','YEMP_STARTDATE_2004_M_01-YEMP_STARTDATE_2004_M_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8STAY ','YEMP_STARTDATE_2004_Y_01-YEMP_STARTDATE_2004_Y_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8STOD ','YEMP_STOPDATE_2004_D_01-YEMP_STOPDATE_2004_D_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8STOM ','YEMP_STOPDATE_2004_M_01-YEMP_STOPDATE_2004_M_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8STOY ','YEMP_STOPDATE_2004_Y_01-YEMP_STOPDATE_2004_Y_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8TEN ','CV_WKSWK_JOB_DLI_2004_01-CV_WKSWK_JOB_DLI_2004_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R8UID ','YEMP_UID_2004_01-YEMP_UID_2004_07 E08 E09 E10 E11 ');
CALL SYMPUT ('R9COM ','CV_HRLY_COMPENSATION_2005_01-CV_HRLY_COMPENSATION_2005_09 E10 E11 ');
CALL SYMPUT ('R9MIL ','YEMP_MILFLAG_2005_01-YEMP_MILFLAG_2005_09 E10 E11 ');
CALL SYMPUT ('R9PAY ','CV_HRLY_PAY_2005_01-CV_HRLY_PAY_2005_09 E10 E11 ');
CALL SYMPUT ('R9SEL ','YEMP_SELFEMP_2005_01-YEMP_SELFEMP_2005_09 E10 E11 ');
CALL SYMPUT ('R9STAD ','YEMP_STARTDATE_2005_D_01-YEMP_STARTDATE_2005_D_09 E10 E11 ');
CALL SYMPUT ('R9STAM ','YEMP_STARTDATE_2005_M_01-YEMP_STARTDATE_2005_M_09 E10 E11 ');
CALL SYMPUT ('R9STAY ','YEMP_STARTDATE_2005_Y_01-YEMP_STARTDATE_2005_Y_09 E10 E11 ');
CALL SYMPUT ('R9STOD ','YEMP_STOPDATE_2005_D_01-YEMP_STOPDATE_2005_D_09 E10 E11 ');
CALL SYMPUT ('R9STOM ','YEMP_STOPDATE_2005_M_01-YEMP_STOPDATE_2005_M_09 E10 E11 ');
CALL SYMPUT ('R9STOY ','YEMP_STOPDATE_2005_Y_01-YEMP_STOPDATE_2005_Y_09 E10 E11 ');
CALL SYMPUT ('R9TEN ','CV_WKSWK_JOB_DLI_2005_01-CV_WKSWK_JOB_DLI_2005_09 E10 E11 ');
CALL SYMPUT ('R9UID ','YEMP_UID_2005_01-YEMP_UID_2005_09 E10 E11 ');
CALL SYMPUT ('R10COM ','CV_HRLY_COMPENSATION_2006_01-CV_HRLY_COMPENSATION_2006_09 E10 E11 ');
CALL SYMPUT ('R10MIL ','YEMP_MILFLAG_2006_01-YEMP_MILFLAG_2006_09 E10 E11 ');
CALL SYMPUT ('R10PAY ','CV_HRLY_PAY_2006_01-CV_HRLY_PAY_2006_09 E10 E11 ');
CALL SYMPUT ('R10SEL ','YEMP_SELFEMP_2006_01-YEMP_SELFEMP_2006_09 E10 E11 ');
CALL SYMPUT ('R10STAD ','YEMP_STARTDATE_2006_D_01-YEMP_STARTDATE_2006_D_09 E10 E11 ');
CALL SYMPUT ('R10STAM ','YEMP_STARTDATE_2006_M_01-YEMP_STARTDATE_2006_M_09 E10 E11 ');
CALL SYMPUT ('R10STAY ','YEMP_STARTDATE_2006_Y_01-YEMP_STARTDATE_2006_Y_09 E10 E11 ');
CALL SYMPUT ('R10STOD ','YEMP_STOPDATE_2006_D_01-YEMP_STOPDATE_2006_D_09 E10 E11 ');
CALL SYMPUT ('R10STOM ','YEMP_STOPDATE_2006_M_01-YEMP_STOPDATE_2006_M_09 E10 E11 ');
CALL SYMPUT ('R10STOY ','YEMP_STOPDATE_2006_Y_01-YEMP_STOPDATE_2006_Y_09 E10 E11 ');
CALL SYMPUT ('R10TEN ','CV_WKSWK_JOB_DLI_2006_01-CV_WKSWK_JOB_DLI_2006_09 E10 E11 ');
CALL SYMPUT ('R10UID ','YEMP_UID_2006_01-YEMP_UID_2006_09 E10 E11 ');

CALL SYMPUT ('R11COM ','CV_HRLY_COMPENSATION_2007_01-CV_HRLY_COMPENSATION_2007_08 E09 E10 E11 ');
CALL SYMPUT ('R11MIL ','YEMP_MILFLAG_2007_01-YEMP_MILFLAG_2007_08 E09 E10 E11 ');
CALL SYMPUT ('R11PAY ','CV_HRLY_PAY_2007_01-CV_HRLY_PAY_2007_08 E09 E10 E11 ');
CALL SYMPUT ('R11SEL ','YEMP_SELFEMP_2007_01-YEMP_SELFEMP_2007_08 E09 E10 E11 ');
CALL SYMPUT ('R11STAD ','YEMP_STARTDATE_2007_D_01-YEMP_STARTDATE_2007_D_08 E09 E10 E11 ');
CALL SYMPUT ('R11STAM ','YEMP_STARTDATE_2007_M_01-YEMP_STARTDATE_2007_M_08 E09 E10 E11 ');
CALL SYMPUT ('R11STAY ','YEMP_STARTDATE_2007_Y_01-YEMP_STARTDATE_2007_Y_08 E09 E10 E11 ');
CALL SYMPUT ('R11STOD ','YEMP_STOPDATE_2007_D_01-YEMP_STOPDATE_2007_D_08 E09 E10 E11 ');
CALL SYMPUT ('R11STOM ','YEMP_STOPDATE_2007_M_01-YEMP_STOPDATE_2007_M_08 E09 E10 E11 ');
CALL SYMPUT ('R11STOY ','YEMP_STOPDATE_2007_Y_01-YEMP_STOPDATE_2007_Y_08 E09 E10 E11 ');
CALL SYMPUT ('R11TEN ','CV_WKSWK_JOB_DLI_2007_01-CV_WKSWK_JOB_DLI_2007_08 E09 E10 E11 ');
CALL SYMPUT ('R11UID ','YEMP_UID_2007_01-YEMP_UID_2007_08 E09 E10 E11 ');

CALL SYMPUT ('R12COM ','CV_HRLY_COMPENSATION_2008_01-CV_HRLY_COMPENSATION_2008_08 E09 E10 E11 ');
CALL SYMPUT ('R12MIL ','YEMP_MILFLAG_2008_01-YEMP_MILFLAG_2008_08 E09 E10 E11 ');
CALL SYMPUT ('R12PAY ','CV_HRLY_PAY_2008_01-CV_HRLY_PAY_2008_08 E09 E10 E11 ');
CALL SYMPUT ('R12SEL ','YEMP_SELFEMP_2008_01-YEMP_SELFEMP_2008_08 E09 E10 E11 ');
CALL SYMPUT ('R12STAD ','YEMP_STARTDATE_2008_D_01-YEMP_STARTDATE_2008_D_08 E09 E10 E11 ');
CALL SYMPUT ('R12STAM ','YEMP_STARTDATE_2008_M_01-YEMP_STARTDATE_2008_M_08 E09 E10 E11 ');
CALL SYMPUT ('R12STAY ','YEMP_STARTDATE_2008_Y_01-YEMP_STARTDATE_2008_Y_08 E09 E10 E11 ');
CALL SYMPUT ('R12STOD ','YEMP_STOPDATE_2008_D_01-YEMP_STOPDATE_2008_D_08 E09 E10 E11 ');
CALL SYMPUT ('R12STOM ','YEMP_STOPDATE_2008_M_01-YEMP_STOPDATE_2008_M_08 E09 E10 E11 ');
CALL SYMPUT ('R12STOY ','YEMP_STOPDATE_2008_Y_01-YEMP_STOPDATE_2008_Y_08 E09 E10 E11 ');
CALL SYMPUT ('R12TEN ','CV_WKSWK_JOB_DLI_2008_01-CV_WKSWK_JOB_DLI_2008_08 E09 E10 E11 ');
CALL SYMPUT ('R12UID ','YEMP_UID_2008_01-YEMP_UID_2008_08 E09 E10 E11 ');

CALL SYMPUT ('R13EHRS ','CVC_HOURS_WK_YR_ET_80-CVC_HOURS_WK_YR_ET_99 CVC_HOURS_WK_YR_ET_00-CVC_HOURS_WK_YR_ET_10 Y11 ');*R13EHRS???;
CALL SYMPUT ('R13EMP ','CVC_TTL_JOB_YR_ET_80-CVC_TTL_JOB_YR_ET_99 CVC_TTL_JOB_YR_ET_00-CVC_TTL_JOB_YR_ET_10 Y11 ');
CALL SYMPUT ('R13EWKS ','CVC_WKSWK_YR_ET_80-CVC_WKSWK_YR_ET_99 CVC_WKSWK_YR_ET_00-CVC_WKSWK_YR_ET_10 Y11 ');
CALL SYMPUT ('R13HRS ','CVC_HOURS_WK_YR_ALL_80-CVC_HOURS_WK_YR_ALL_99 CVC_HOURS_WK_YR_ALL_00-CVC_HOURS_WK_YR_ALL_10 Y11 ');
CALL SYMPUT ('R13JOB ','CVC_TTL_JOB_YR_ALL_80-CVC_TTL_JOB_YR_ALL_99 CVC_TTL_JOB_YR_ALL_00-CVC_TTL_JOB_YR_ALL_10 Y11 ');
CALL SYMPUT ('R13SELF ','Y80 Y81 Y82 Y83 Y84 Y85 Y86 Y87 Y88 Y89 Y90 Y91 Y92 Y93 Y94 Y95 Y96 Y97 CVC_TTL_JOB_YR_SE_98 CVC_TTL_JOB_YR_SE_99 CVC_TTL_JOB_YR_SE_00-CVC_TTL_JOB_YR_SE_10 Y11 ');
CALL SYMPUT ('R13SHRS ','Y80 Y81 Y82 Y83 Y84 Y85 Y86 Y87 Y88 Y89 Y90 Y91 Y92 Y93 Y94 Y95 Y96 Y97 CVC_HOURS_WK_YR_SE_98 CVC_HOURS_WK_YR_SE_99 CVC_HOURS_WK_YR_SE_00-CVC_HOURS_WK_YR_SE_10 Y11 ');
CALL SYMPUT ('R13SWKS ','Y80 Y81 Y82 Y83 Y84 Y85 Y86 Y87 Y88 Y89 Y90 Y91 Y92 Y93 Y94 Y95 Y96 Y97 CVC_WKSWK_YR_SE_98 CVC_WKSWK_YR_SE_99 CVC_WKSWK_YR_SE_00-CVC_WKSWK_YR_SE_10 Y11 ');
CALL SYMPUT ('R13WKS ','CVC_WKSWK_YR_ALL_80-CVC_WKSWK_YR_ALL_99 CVC_WKSWK_YR_ALL_00-CVC_WKSWK_YR_ALL_10 Y11 ');

CALL SYMPUT ('R13COM ','CV_HRLY_COMPENSATION_2009_01-CV_HRLY_COMPENSATION_2009_09 E10 E11 ');
CALL SYMPUT ('R13MIL ','YEMP_MILFLAG_2009_01-YEMP_MILFLAG_2009_09 E10 E11 ');
CALL SYMPUT ('R13PAY ','CV_HRLY_PAY_2009_01-CV_HRLY_PAY_2009_09 E10 E11 ');
CALL SYMPUT ('R13SEL ','YEMP_SELFEMP_2009_01-YEMP_SELFEMP_2009_08 E09 E10 E11 ');
CALL SYMPUT ('R13STAD ','YEMP_STARTDATE_2009_D_01-YEMP_STARTDATE_2009_D_09 E10 E11 ');
CALL SYMPUT ('R13STAM ','YEMP_STARTDATE_2009_M_01-YEMP_STARTDATE_2009_M_09 E10 E11 ');
CALL SYMPUT ('R13STAY ','YEMP_STARTDATE_2009_Y_01-YEMP_STARTDATE_2009_Y_09 E10 E11 ');
CALL SYMPUT ('R13STOD ','YEMP_STOPDATE_2009_D_01-YEMP_STOPDATE_2009_D_09 E10 E11 ');
CALL SYMPUT ('R13STOM ','YEMP_STOPDATE_2009_M_01-YEMP_STOPDATE_2009_M_09 E10 E11 ');
CALL SYMPUT ('R13STOY ','YEMP_STOPDATE_2009_Y_01-YEMP_STOPDATE_2009_Y_09 E10 E11 ');
CALL SYMPUT ('R13TEN ','CV_WKSWK_JOB_DLI_2009_01-CV_WKSWK_JOB_DLI_2009_09 E10 E11 ');
CALL SYMPUT ('R13UID ','YEMP_UID_2009_01-YEMP_UID_2009_09 E10 E11 ');

proc sort; by pubid;

proc means;
run;   
               
data empstatus; set r14.empstatus;

proc format;
value vx0f
  0='0: No information reported to account for week; job dates indeterminate'
  1='1: Not associated with an employer, not actively searching for an employer job'
  2='2: Not working (unemployment vs. out of labor force cannot be determined)'
  3='3: Associated with an employer, periods not working for the employer are missing'
  4='4: Unemployed'
  5='5: Out of the labor force'
  6='6: Active military service'
  9701-200810='9701 TO 200810: Employer on roster (see YEMP_UID)';
value vx313f
  9701-9707='9701 TO 9707: Unique Employer ID (see YEMP_UID)'
  9801-9809='9801 TO 9809: Unique Employer ID (see YEMP_UID)'
  199900-199999='199900 TO 199999: Unique Employer ID (see YEMP_UID)'
  200000-200099='200000 TO 200099: Unique Employer ID (see YEMP_UID)'
  200100-200199='200100 TO 200199: Unique Employer ID (see YEMP_UID)'
  200200-200299='200200 TO 200299: Unique Employer ID (see YEMP_UID)'
  200300-200399='200300 TO 200399: Unique Employer ID (see YEMP_UID)'
  200400-200499='200400 TO 200499: Unique Employer ID (see YEMP_UID)'
  200500-200599='200500 TO 200599: Unique Employer ID (see YEMP_UID)';

proc means;   
run;

data emp_deny;
merge two(keep= pubid
                YEMP_9899M_01 YEMP_9899M_02
                YEMP_9899M_03 YEMP_9899M_04
                YEMP_9899M_05 YEMP_9899M_06
                YEMP_9899M_07 YEMP_9899M_08)
      one(keep= pubid
                YEMP_UID_2009_01-YEMP_UID_2009_09
                YEMP_UID_2008_01-YEMP_UID_2008_08
                YEMP_UID_2007_01-YEMP_UID_2007_08
                YEMP_UID_2006_01-YEMP_UID_2006_09
                YEMP_UID_2005_01-YEMP_UID_2005_09
                YEMP_UID_2004_01-YEMP_UID_2004_07
                YEMP_UID_2003_01-YEMP_UID_2003_10
                YEMP_UID_2002_01-YEMP_UID_2002_11
                YEMP_UID_2001_01-YEMP_UID_2001_08
                YEMP_UID_2000_01-YEMP_UID_2000_09);
by pubid;*no "by pubid" in totalXR13;

if YEMP_9899M_01> -5; *exclude noninterviews;
 
array r13uid YEMP_UID_2009_01-YEMP_UID_2009_09;
array r12uid YEMP_UID_2008_01-YEMP_UID_2008_08 E09;
array r11uid YEMP_UID_2007_01-YEMP_UID_2007_08 E09;
array r10uid YEMP_UID_2006_01-YEMP_UID_2006_09;
array r9uid  YEMP_UID_2005_01-YEMP_UID_2005_09;
array r8uid  YEMP_UID_2004_01-YEMP_UID_2004_07 E08 E09;
array r7uid  YEMP_UID_2003_01-YEMP_UID_2003_09;*Sa notes: no S3589800 or YEMP_UID_2003_10?;
array r6uid  &r6uid;
array r5uid  YEMP_UID_2001_01-YEMP_UID_2001_08 E09;
array r4uid  YEMP_UID_2000_01-YEMP_UID_2000_09;
array dliuid dliuid1-dliuid9;

do over dliuid;
  if r13uid>0 then dliuid=r13uid;
  if r13uid le 0 and r12uid>0 then dliuid=r12uid;
  if r13uid le 0 and r12uid le 0 and r11uid>0 then dliuid=r11uid;
  if r13uid le 0 and r12uid le 0 and r11uid le 0 and r10uid>0 then dliuid=r10uid;
  if r13uid le 0 and r12uid le 0 and r11uid le 0 and r10uid le 0 and r9uid>0 then dliuid=r9uid;  
  if r13uid le 0 and r12uid le 0 and r11uid le 0 and r10uid le 0 and r9uid le 0 and r8uid>0 then dliuid=r8uid;
  if r13uid le 0 and r12uid le 0 and r11uid le 0 and r10uid le 0 and r9uid le 0 and r8uid le 0 and r7uid>0 then dliuid=r7uid;
  if r13uid le 0 and r12uid le 0 and r11uid le 0 and r10uid le 0 and r9uid le 0 and r8uid le 0 and r7uid le 0 and r6uid>0
         then dliuid=r6uid;
  if r13uid le 0 and r12uid le 0 and r11uid le 0 and r10uid le 0 and r9uid le 0 and r8uid le 0 and r7uid le 0 and r6uid le 0
         and r5uid>0 then dliuid=r5uid;
  if r13uid le 0 and r12uid le 0 and r11uid le 0 and r10uid le 0 and r9uid le 0 and r8uid le 0 and r7uid le 0 and r6uid le 0
         and r5uid le 0 and r4uid>0 then dliuid=r4uid;
end;

array E9899M &E9899m;

do over E9899M;
    if e9899m=2 and deny1>0 and deny2=. then deny2=dliuid;
    if e9899m=2 and deny1=. then deny1=dliuid;
end;

title2 'emp_deny';
proc means data=emp_deny; var pubid deny1 deny2;

proc freq data=emp_deny;
tables deny1*(YEMP_9899M_01 YEMP_9899M_02 YEMP_9899M_03 YEMP_9899M_04 YEMP_9899M_05 YEMP_9899M_06 YEMP_9899M_07 YEMP_9899M_08)/norow nocol nopercent missing;
run;

data total_numwks;
merge one
       r14.emp_int
      r14.emp_week(keep=pubid bstar dliwk)
      r14.emp29_numwks
      empstatus;
by pubid;

array intwk r1int -- r13int;
C=0;

do over intwk; C+1;
  if intwk>0 then do;
    dliwk=intwk;
    dli_r=C;
  end;
end;

if r0int>-5 then dli_r=14;
array rXwks  (i) &R13WKS;  * DLI created variable, all jobs;   
array rXswks (i) &R13SWKS; * DLI created variable, employee jobs;
array rXewks (i) &R13EWKS; * DLI created variable, self-employed jobs;

array r0wks  (i) R0wks80-R0wks99   R0wks00-R0wks11;   * Current Round created variable, all jobs;
array r0swks (i) Y80-Y97 R0swks98-R0swks99 R0swks00-R0swks11; * Current Round created variable, self-employed jobs;
array r0ewks (i) R0ewks80-R0ewks99 R0ewks00-R0ewks11; * Current Round created variable, employee jobs;
array twks   (i) twks80-twks99    twks00-twks11;     * Total created variable, all jobs;
array tewks  (i) tewks80-tewks99  tewks00-tewks11;   * Total created variable, employee jobs;
array tswks  (i) Y80-Y97 tswks98-tswks99 tswks00-tswks11; * Total created variable, self-employed jobs;

do over twks;
   twks=0; tswks=0; tewks=0;
   if r0wks>0 then twks=twks+r0wks; if r0wks in (-1,-2,-3) then twks=-3;
   if r0swks>0 then tswks=tswks+r0swks; if r0swks in (-1,-2,-3) then tswks=-3;
   if r0ewks>0 then tewks=tewks+r0ewks; if r0ewks in (-1,-2,-3) then tewks=-3;

   if twks ne -3 and rXwks>0 then twks=twks+rXwks; if rXwks in (-1,-2,-3) then twks=-3;
   if tswks ne -3 and rXswks>0 then tswks=tswks+rXswks; if rXswks in (-1,-2,-3) then tswks=-3;
   if tewks ne -3 and rXewks>0 then tewks=tewks+rXewks; if rXewks in (-1,-2,-3) then tewks=-3;
end;
      
 
drop Y80-Y97;

* For backreporters use event history to calculate bchange -
  back reported weeks from R0 that would change event history from not working to working;

/*from event history emp_status*/
array r7ar  (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;  

if bstar>0 then do;
    bchange=0;
    do i=bstar to dliwk;
           if r7ar=0 then bchange=bchange+1;   
    end;
end;
drop _1-_730;

proc means data=total_numwks; *class pubid; *where r0int=-5;
title 'total_numwks';
var r1int -- r13int r0int dliwk
     twks80-twks99 twks00-twks11
     tewks80-tewks99 tewks00-tewks11
     tswks98-tswks99 tswks00-tswks11 bchange;  
run;
       

data match; merge one two; by pubid;
*Find most recent prior round for all current round nonmilitary uids.
*Define "match1_4" as follows: when L4 in the current round is not a military job and
 has the same uid as L1 in round9, match1_4=9 ;
*For uids in multiple prior rounds, find the most recent match;
*Uids that are new in the current round have no matches;
*Umatch is the uid that is matched;

array r0uid  (j)  &R0uid;   
array r0mil  (j)  &R0mil;
array r13uid (i)  &R13uid;
array r12uid (i)  &R12uid;
array r11uid (i)  &R11uid;
array r10uid (i)  &R10uid;
array r9uid  (i)  &R9uid;
array r8uid  (i)  &R8uid;   
array r7uid  (i)  &R7UID;
array r6uid  (i)  &R6uid;
array r5uid  (i)  &R5UID;
array r4uid  (i)  &R4uid;
array r3uid  (i)  &R3uid;
array r2uid  (i)  &R2UID;
array r1uid  (i)  &R1uid;

array match {12,9} match1_1-match1_9 match2_1-match2_9
                   match3_1-match3_9 match4_1-match4_9
                   match5_1-match5_9 match6_1-match6_9
                   match7_1-match7_9 match8_1-match8_9
                   match9_1-match9_9 match10_1-match10_9
                   match11_1-match11_9 match12_1-match12_9;

do i=1 to 9;
  if r1uid>0 then do;
    do j=1 to 9;      
      if r0mil ne 1 and r1uid=r0uid and r2uid ne r0uid and r3uid ne r0uid and r4uid ne r0uid and
        r5uid ne r0uid and r6uid ne r0uid and r7uid ne r0uid and
        r8uid ne r0uid and r9uid ne r0uid and r10uid ne r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=1;
    end;
  end;
end;

do i=1 to 9;
  if r2uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r2uid=r0uid and r3uid ne r0uid and r4uid ne r0uid and
        r5uid ne r0uid and r6uid ne r0uid and r7uid ne r0uid and
        r8uid ne r0uid and r9uid ne r0uid and R10uid ne r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=2;
    end;
  end;
end;
do i=1 to 9;
  if r3uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r3uid=r0uid and r4uid ne r0uid and
        r5uid ne r0uid and r6uid ne r0uid and r7uid ne r0uid and
        r8uid ne r0uid and r9uid ne r0uid and R10uid ne r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=3;
    end;
  end;
end;
do i=1 to 9;
  if r4uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r4uid=r0uid and
        r5uid ne r0uid and r6uid ne r0uid and r7uid ne r0uid and
        r8uid ne r0uid and r9uid ne r0uid and R10uid ne r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=4;
    end;
  end;
end;
do i=1 to 8;
  if r5uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r5uid=r0uid and r6uid ne r0uid and r7uid ne r0uid
         and r8uid ne r0uid and r9uid ne r0uid and R10uid ne r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=5;
    end;
  end;
end;
do i=1 to 11;
  if r6uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r6uid=r0uid and r7uid ne r0uid and r8uid ne r0uid
          and r9uid ne r0uid and R10uid ne r0uid and r11uid ne r0uid  and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=6;
    end;
  end;
end;
do i=1 to 10;
  if r7uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r7uid=r0uid and r8uid ne r0uid and r9uid ne r0uid
          and R10uid ne r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=7;                                     
    end;   
  end;  
end;
do i=1 to 7;
  if r8uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r8uid=r0uid and r9uid ne r0uid and R10uid ne r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=8;                                         
    end;   
  end;  
end;
do i=1 to 9;
  if r9uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r9uid=r0uid and R10uid ne r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=9;                                          
    end;   
  end;  
end;
do i=1 to 9;
  if r10uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r10uid=r0uid and r11uid ne r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=10;                                           
    end;   
  end;  
end;
do i=1 to 9;
  if r11uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r11uid = r0uid and
        r12uid ne r0uid and r13uid ne r0uid then match(i,j)=11;                                         
    end;   
  end;  
end;

do i=1 to 9;
  if r12uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r12uid = r0uid and r13uid ne r0uid then match(i,j)=12;                                   
    end;   
  end;  
end;

do i=1 to 9;
  if r13uid>0 then do;
    do j=1 to 9;
      if r0mil ne 1 and r13uid = r0uid then match(i,j)=13;                                   
    end;   
  end;  
end;

array match1  (j) match1_1-match1_9;
array match2  (j) match2_1-match2_9;
array match3  (j) match3_1-match3_9;
array match4  (j) match4_1-match4_9;
array match5  (j) match5_1-match5_9;
array match6  (j) match6_1-match6_9;
array match7  (j) match7_1-match7_9;
array match8  (j) match8_1-match8_9;
array match9  (j) match9_1-match9_9;
array match10 (j) match10_1-match10_9;
array match11 (j) match11_1-match11_9;

do over match1;  
  if match1 ne max(of match1-match11) then match1=.;
  if match2 ne max(of match1-match11) then match2=.;
  if match3 ne max(of match1-match11) then match3=.;
  if match4 ne max(of match1-match11) then match4=.;
  if match5 ne max(of match1-match11) then match5=.;
  if match6 ne max(of match1-match11) then match6=.;  
  if match7 ne max(of match1-match11) then match7=.;  
  if match8 ne max(of match1-match11) then match8=.;  
  if match9 ne max(of match1-match11) then match9=.;  
  if match10 ne max(of match1-match11) then match10=.;  
end;
 
proc means data=match;
var pubid match: /*umatch1_1 -- umatch8_9*/;
run;

data total_tenure;                                                                                 
merge one r14.emp_int r14.emp32_jobten match;
by pubid;
 
if r0int>-5;
*Update tenure for each job reported in current round;
array match1  (j) match1_1-match1_9;
array match2  (j) match2_1-match2_9;
array match3  (j) match3_1-match3_9;
array match4  (j) match4_1-match4_9;
array match5  (j) match5_1-match5_9;
array match6  (j) match6_1-match6_9;   
array match7  (j) match7_1-match7_9;
array match8  (j) match8_1-match8_9;
array match9  (j) match9_1-match9_9;
array match10 (j) match10_1-match10_9;
array match11 (j) match11_1-match11_9;
array r0ten   (j) r0ten1-r0ten9;                                                                  
array totten  (j) totten1-totten9;                                                            

do j=1 to 9;               
   totten=0;
   if r0ten ne . then totten=totten+r0ten;     
end;        
                                                        
array match {11,9} match1_1-match1_9 match2_1-match2_9 match3_1-match3_9
                   match4_1-match4_9 match5_1-match5_9 match6_1-match6_9
                    match7_1-match7_9 match8_1-match8_9 match9_1-match9_9
                   match10_1-match10_9 match11_1-match11_9;  
array r13ten(i)  &R13ten;
array r12ten(i)  &R12ten;
array r11ten(i)  &R11ten;
array r10ten(i)  &R10ten;
array r9ten (i)  &R9ten;   
array r8ten (i)  &R8ten;                                                                                           
array r7ten (i)  &R7ten;                                  
array r6ten (i)  &R6ten;
array r5ten (i)  &R5ten;
array r4ten (i)  &R4ten;             
array r3ten (i)  &R3ten;
array r2ten (i)  &R2ten;
array r1ten (i)  &R1ten;

do j=1 to 9;
   if totten ge 0 then do;
     do i=1 to 11;
      if match(i,j)=13 and r13ten>0 then totten=totten+r13ten;
      if match(i,j)=13 and r13ten=-3 then totten=-3;
      if match(i,j)=12 and r12ten>0 then totten=totten+r12ten;
      if match(i,j)=12 and r12ten=-3 then totten=-3;
      if match(i,j)=11 and r11ten>0 then totten=totten+r11ten;
      if match(i,j)=11 and r11ten=-3 then totten=-3;
      if match(i,j)=10 and r10ten>0 then totten=totten+r10ten;
      if match(i,j)=10 and r10ten=-3 then totten=-3;
      if match(i,j)=9 and r9ten>0 then totten=totten+r9ten;
      if match(i,j)=9 and r9ten=-3 then totten=-3;
      if match(i,j)=8 and r8ten>0 then totten=totten+r8ten;
      if match(i,j)=8 and r8ten=-3 then totten=-3;
      if match(i,j)=7 and r7ten>0 then totten=totten+r7ten;
      if match(i,j)=7 and r7ten=-3 then totten=-3;
      if match(i,j)=6 and r6ten>0 then totten=totten+r6ten;
      if match(i,j)=6 and r6ten=-3 then totten=-3;
      if match(i,j)=5 and r5ten>0 then totten=totten+r5ten;
      if match(i,j)=5 and r5ten=-3 then totten=-3;
      if match(i,j)=4 and r4ten>0 then totten=totten+r4ten;
      if match(i,j)=4 and r4ten=-3 then totten=-3;
      if match(i,j)=3 and r3ten>0 then totten=totten+r3ten;
      if match(i,j)=3 and r3ten=-3 then totten=-3;
      if match(i,j)=2 and r2ten>0 then totten=totten+r2ten;
      if match(i,j)=2 and r2ten=-3 then totten=-3;
      if match(i,j)=1 and r1ten>0 then totten=totten+r1ten;
      if match(i,j)=1 and r1ten=-3 then totten=-3;
     end;
   end;
end;                             

proc means data=total_tenure;
var pubid totten1-totten9 ;
title2 'total_tenure';
run;

data total_anhrs;                                                               
merge one r14.emp_int r14.emp33_anhours;by pubid;                        
 
array thrs   (k) thrs80-thrs99 thrs00-thrs11;                                                  
array tshrs  (k) Y80-Y97 tshrs98-tshrs99 tshrs00-tshrs11;                                                  
array tehrs  (k) tehrs80-tehrs99 tehrs00-tehrs11;                                                  
array rXhrs  (k) &R13hrs;                                             
array rXshrs (k) &R13shrs;                                              
array rXehrs (k) &R13ehrs;

array r0hrs  (k) r0hrs80-r0hrs99 r0hrs00-r0hrs11;                                               
array r0shrs (k) Y80-Y97 r0shrs98-r0shrs99 r0shrs00-r0shrs11;                                              
array r0ehrs (k) r0ehrs80-r0ehrs99 r0ehrs00-r0ehrs11;
 
*Total annual hours is current annual hours + annual hours from dli,
by calendar year;                                                                                                 
do k=1 to 32;                                                                                   
       thrs=0; tshrs=0; tehrs=0;  
       if r0hrs>0 then thrs=thrs+r0hrs;
    if -4<r0hrs<0 then thrs=r0hrs;                                                                    
       if r0shrs>0 then tshrs=tshrs+r0shrs;
    if -4<r0shrs<0 then tshrs=r0shrs;                                                                  
       if r0ehrs>0 then tehrs=tehrs+r0ehrs;
    if -4<r0ehrs<0 then tehrs=r0ehrs;

       if thrs ne -3 and rXhrs>0 then thrs=thrs+rXhrs;  
    if -4<rXhrs<0 then thrs=rXhrs;
       if tshrs ne -3 and rXshrs>0 then tshrs=tshrs+rXshrs;   
    if -4<rXshrs<0 then tshrs=rXshrs;
       if tehrs ne -3 and rXehrs>0 then tehrs=tehrs+rXehrs;
    if -4<rXehrs<0 then tehrs=rXehrs;
end;

proc means data=total_anhrs;
var thrs80-thrs99 thrs00-thrs11
    tshrs98-tshrs99 tshrs00-tshrs11
    tehrs80-tehrs99 tehrs00-tehrs11;  
title2 'total_anhrs';
run;

data total_wksage14;
merge one r14.emp_int r14.emp34_wksage14; by pubid;  

*rename variables from prior rounds;
rXewks14=CVC_WKSWK_TEEN;
rXewks20=CVC_WKSWK_ADULT_ET;
rXwks20=CVC_WKSWK_ADULT_ALL;
                              
twks20=0; tewks20=0; tewks14=0;
       if r0wks20>0 then twks20=twks20+r0wks20;
       if r0ewks20>0 then tewks20=tewks20+r0ewks20;
       if r0ewks14>0 then tewks14=tewks14+r0ewks14;
       if r0wks20 in (-3) then twks20=-3;
       if r0ewks20 in (-3) then tewks20=-3;
       if r0ewks14 in (-3) then tewks14=-3;

      if twks20 not in (-3) and rXwks20>0 then twks20=twks20+rXwks20;
      if rXwks20=-3 then twks20=-3;
      if tewks20 not in (-3) and rXewks20>0 then tewks20=tewks20+rXewks20;
      if rXewks20=-3 then tewks20=-3;
      if tewks14 not in (-3) and rXewks14>0 then tewks14=tewks14+rXewks14;
      if rXewks14=-3 then tewks14=-3;

proc means data=total_wksage14;
title2 'total_wksage14';
var twks20 tewks20 tewks14 r0ewks14
    CVC_WKSWK_TEEN CVC_WKSWK_ADULT_ET CVC_WKSWK_ADULT_ALL;
run;                                                                     

data total_hrsage14;
merge one r14.emp_int r14.emp35_hrsage14; by pubid;    

rXehrs14=CVC_HOURS_WK_TEEN;
rXehrs20=CVC_HOURS_WK_ADULT_ET;
rXhrs20=CVC_HOURS_WK_ADULT_ALL;

tehrs14=0; thrs20=0; tehrs20=0;                          
*Want only hrs from employee type jobs for age 14-19.
All hrs R3 and earlier are assumed to be from employee type jobs;                                  
if r0ehrs14=>0 then tehrs14=tehrs14+r0ehrs14;                                                              
if r0ehrs14=-3 then tehrs14=-3;
/*No R is age 20 until R3, and none age20 in R3 has dliwk=r3int*/
if r0ehrs20=>0 then tehrs20=tehrs20+r0ehrs20;                                                              
if r0ehrs20=-3 then tehrs20=-3;
if r0hrs20=>0 then thrs20=thrs20+r0hrs20;                                                              
if r0hrs20=-3 then thrs20=-3;

if tehrs14 ge 0 then do;
  if rXehrs14>0 then tehrs14=tehrs14+rXehrs14;
  if rXehrs14=-3 then tehrs14=-3;
end;

if tehrs20 ge 0 then do;
  if rXehrs20>0 then tehrs20=tehrs20+rXehrs20;
  if rXehrs20=-3 then tehrs20=-3;
end;

if thrs20 ge 0 then do;
  if rXhrs20>0 then thrs20=thrs20+rXhrs20;
  if rXhrs20=-3 then thrs20=-3;
end;
                                                        
proc means data=total_hrsage14;
title2 'total_hrsage14';
var thrs20 tehrs20 tehrs14;
run;

proc means data=r14.emp36_numjobs;

data total_numjobs;
merge one r14.emp36_numjobs; by pubid;   

array rXjob  (k) &R13job;                                          
array rXself (k) &R13self;                                              
array rXemp  (k) &R13emp;
array r0job  (k) r0job80-r0job99 r0job00-r0job11;                                          
array r0self (k) r0self80-r0self99 r0self00-r0self11;                                              
array r0emp  (k) r0emp80 -r0emp99  r0emp00 -r0emp11;                                                     
array tjob   (k) tjob80-tjob99 tjob00-tjob11;                                                       
array tsjob  (k) tsjob80-tsjob99 tsjob00-tsjob11;                                                   
array tejob  (k) tejob80-tejob99 tejob00-tejob11;

do over tjob;   
    tjob=rXjob;                                                                              
    tsjob=rXself;                                                                                        
    tejob=rXemp;  
    if tjob=. then tjob=0;
    if tsjob=. then tsjob=0;
    if tejob=. then tejob=0;
    if tjob ge 0 and r0job=-3 then tjob=-3;
    if tsjob ge 0 and r0self=-3 then tsjob=-3;
    if tejob ge 0 and r0emp=-3 then tejob=-3;
    if tjob ge 0 and r0job>0 then tjob=tjob+r0job;   
    if tsjob ge 0 and r0self>0 then tsjob=tsjob+r0self;
    if tejob ge 0 and r0emp>0 then tejob=tejob+r0emp;
end;                     

proc means data=total_numjobs;
var pubid tjob80-tjob99 tjob00-tjob11 tejob80-tejob99 tejob00-tejob11
    tsjob80-tsjob99 tsjob00-tsjob11;
run;

data total_numjobs14;
 merge one r14.emp_int r14.emp37_numjobs14; by pubid;                                                                                         

/*No R is age 20 until R3, and none age20 in R3 has dliwk=r3int*/
rXemp14=CVC_TTL_JOB_TEEN;
rXemp20=CVC_TTL_JOB_ADULT_ET;
rXjob20=CVC_TTL_JOB_ADULT_ALL;

array totjob totjob20 totemp20 totemp14;
array r0job  r0job20  r0emp20  r0emp14;
array rXjob  rXjob20  rXemp20  rXemp14;

do over totjob;   
   totjob=rXjob;
   if totjob ge 0 and r0job=-3 then totjob=-3;
   if totjob ge 0 and r0job>0 then totjob=totjob+r0job;         
end;

proc means data=total_numjobs14;
title2 'total_numjobs14';
var totemp14 totemp20 totjob20;  
run;

data total_cvc(keep=pubid r1int--r13int r0int dliwk dli_r twks80--totemp14);
merge                         
total_numwks(keep=pubid twks80-twks99 twks00-twks11                 
                  tewks80-tewks99 tewks00-tewks11 tswks98-tswks99 tswks00-tswks11
                  bchange r1int--r13int r0int dliwk dli_r)
total_anhrs(keep=pubid thrs80-thrs99 thrs00-thrs11                   
                 tshrs98-tshrs99 tshrs00-tshrs11 tehrs80-tehrs99 tehrs00-tehrs11)
total_wksage14(keep=pubid tewks14 twks20 tewks20)
total_hrsage14(keep=pubid tehrs14 thrs20 tehrs20)        
total_numjobs(keep=pubid tjob80-tjob99 tjob00-tjob11                                          
                   tejob80-tejob99 tejob00-tejob11 tsjob98-tsjob99 tsjob00-tsjob11)    
total_numjobs14(keep=pubid totemp14 totjob20 totemp20)
r14.emp_int;by pubid;

data total;
merge emp_deny(keep=pubid deny1)
      total_tenure(keep=pubid totten1-totten9)
      total_cvc; by pubid;

array miss deny1--totemp20;

do over miss;
    if miss=. and r0int=-5 then miss=-5;
    if miss=. and r0int>0 then miss=-4;
end;
endsas;