Skip to main content
National Longitudinal Survey of Youth 1979 (NLSY79)

NLSY79 Appendix 18: Work History Data

NLSY79 Week Numbers and Corresponding Dates crosswalk file (.xlsx). The Continuous Week Crosswalk contains the start date for each week (Sunday) from January 1, 1978, through September 3, 2023, and the week numbers assigned to that week in the construction of the work history data file. These week numbers do not match the week numbers printed on the employment calendar included with the survey instrument materials for earlier survey years. Week numbers in the work history programs are assigned based upon actual dates collected during the course of the interview. The variable names for the week-by-week arrays (status, hours, dual jobs) incorporate the specific year and number of the week within the specific year. For example, the 10th week in 1989 in the status array is called STAT8910. These names do not correspond to the strictly consecutive week numbers from 1-2384 listed in the Excel spreadsheet. The spreadsheet also contains the week numbers for each calendar year so that users will have a crosswalk for both calendar-year and continuous week numbers.

Description of the 1979-2022 NLSY79 Work History program

This document provides a general explanation of the procedures and logic of the work history programming and variables. The original PL/I programming was used to establish and maintain the structure and data from survey years 1979 to 1994. Therefore, the following discussion heavily references these programs. The series of SQL programs currently in use were converted directly from the PL/I code for the 1996 release.

The original PL/I work history program was written to create key work variables like "Number of Weeks Worked since Date of Last Interview," "Number of Weeks Worked in Last Calendar Year," etc. These key variables use all recorded jobs for each respondent (up to 10 jobs). The WEEKLY LABOR STATUS, HOURS WORKED, and DUAL JOB arrays also were created with data from up to 10 jobs for each respondent. However, only 1% of all respondents have more than 5 jobs in any given survey year, resulting in valid missing data for jobs 6 through 10 for 99% of the sample. In order to reduce the total number of variables, public data files contain the specific employer variables for only 5 jobs for each respondent.

The purpose of the WEEKLY LABOR STATUS, HOURS WORKED and DUAL JOB arrays are to create a longitudinal work history record for each respondent through the 2022 (round 30) interview date. Because each round's survey collects information on jobs held and periods not working since the date of the last interview, it is possible to construct a continuous, week-by-week record for each respondent.

There are a few exceptions, however. In the 1979 and 1980 surveys, job information was collected only for respondents age 16 and older at the date of the interview. Additionally, the 1979 survey data contain the most cases with inconsistent or invalid employment-related data of any survey year, resulting in a greater proportion of missing gaps in the work history record. For example, in 1979 there are 86 cases that have job dates that exceed the interview date; in 1980, there are 11 cases that have job dates that exceed the interview date; in 1981 there are none.

Users should also note that 1,079 members of the military sample were dropped as of the 1985 survey. In 1991, all members of the economically disadvantaged non-black/non-Hispanic oversample were dropped as well. More information on these sample types is available in the Retention and Reasons for Noninterview section.

Description of the 1979-1994 PL/1 program

The following is an abbreviated step-by-step description of the original 1979-1994 PL/I programming. In 1996, the PL/I program was converted to SQL code in a series of programs that replicate the PL/I program and functions.

  1. All of the variables used in the program are declared and most are included in the PL/I structure called VARIABLES.
  2. The variables common to all respondents, like ID, SAMPLE_ID, etc. are assigned values. The week-by-week arrays are initialized to zero and all of the variables included in the WORK_HISTORY part of the structure are initialized to -4.
  3. For each interview year, procedures (VARIABLES1979, VARIABLES1980, etc.) that assign the variables for each survey year are called if the respondent was interviewed. Start and stop dates for jobs and periods not working are sent to the WEEK procedure, where the valid month, day and year variables are converted to a week number, with week 1 being January 1, 1978. If the respondent was not interviewed, then all WORK_HISTORY variables for that survey year are set to -5.
  4. After all VARIABLES19XX are assigned, the procedure CALC is called to evaluate the various start and stop dates, to assign codes, and to create the job number for all of the jobs for each interview year. Within CALC, the procedure FILL is called to fill in the codes that are assigned to the WEEKLY LABOR STATUS and DUAL JOB arrays and to calculate the hours worked during each week that are loaded into the HOURS WORKED array.
  5. Finally, the procedure SUMMER is called to calculate and sum the key work history variables.

CALC procedure (in original PL/1 program)

This procedure processes all jobs for each survey year, beginning with the first job. CALC starts by calculating each year the number of jobs since the date of the last interview, assigning a job number, and calculating the hourly wage for each job. If the respondent had the job at the date of the last interview, the start date becomes the date of the last interview, which is then "ceiled" or rounded up using the "ceil" function. Next, if the respondent is currently working at the job, it assigns the interview date, which is "floored" or rounded down using the "floor" function, as the stop date. (All dates at this point have been converted to week numbers in the WEEK procedure.)

If the start and stop dates of the job are valid and do not coincide with an interview date, the start and stop dates are "ceiled." The number of weeks tenure on the job is calculated by subtracting the start week from the stop week of the job. FILL is then called to fill in the week arrays for the particular job. The start and stop weeks of the job, the job number, and the number of hours usually worked per week (HOURSWEEK) at the job are sent to the FILL procedure.

If the job had any periods not working associated with it, then up to four periods not working for the employer are processed. If the start and stop dates for the periods not working are valid, a code is assigned indicating whether the respondent was out of the labor force (OLF) or unemployed for the period. If the respondent is OLF the whole period, a code of 4 is assigned. If the period not working is divided between OLF and unemployed, a temporary code of 9 is assigned and the number of weeks unemployed is determined. If the start and stop dates of the period are valid, but the labor force status cannot be determined, a code of 2 is assigned.

The period start and stop dates, CODE, and HOURSWEEK are sent to FILL. If the period dates are invalid, a code of 3 is assigned and start and stop dates of the job are passed to FILL, along with HOURSWEEK. This is only done for the first period not working for the first employer this week.

Next, tenure at the job is again calculated, this time in terms of total weeks on the job instead of just since the date of the last interview. First, a determination is made to see if the employer is the same employer a respondent reported at the time of the previous interview. If there is a previous employer number and the tenure for that previous employer is valid, then the tenure for the job from the previous interview is added to the tenure for the job being processed. Only tenure with an employer that is reported during contiguous survey years can be calculated over the total time spent with an employer. For example, consider a respondent who was interviewed in 1981, 1982 and 1983 surveys. Now suppose the respondent reported having worked for the Department of Labor at the time of the 1981 survey and left and then began working for that same employer again by the time of the 1983 survey. Because the employer numbers are only followed between contiguous interviews, there is no way to calculate total tenure with the Labor Department since the respondent did not report that employer during the 1982 survey. Only employers from the previous year's survey are compared with employers reported in the current year's survey.

Finally, CALC evaluates up to six periods not working or in the military between jobs. For each of the periods not working, the same logic used for the periods not working on a job is used for the periods between jobs.

Important information: Invalid start/stop dates

  1. If the start and stop dates for a job are invalid, then that job has no dates that can be sent to FILL. As a result, there is no record of that job in the WEEKLY LABOR STATUS array and no indication that the job is missing. In 1979, there were 1190 cases with any invalid start or stop dates (i.e., at least one week is unaccounted for - WEEKLY LABOR STATUS=0); in 1980, there were 942 cases; in 1981, there were 254; and in each of the following survey years, there were fewer than 200 cases.
  2. A job held in any day of a week is counted as a job for the whole week. This is achieved by "flooring" start dates and "ceiling" stop job dates to integer week values. There is one exception previously mentioned--stop dates for jobs held at the interview date are floored. This is done to avoid double counting across interview years.
  3. tart and stop dates for periods not working either within tenure with a job or between jobs are "ceiled" in FILL.
  4. The HOURS WORKED array is set to -3 if any job in the week has an invalid value for HOURSWEEK. Between 1979 and 1992, the maximum number of hours for any given week is 96. Beginning in 1993, the maximum number of hours for a given week can be reported up to 168 hours (the total number of hours possible in a single week).

FILL procedure

The FILL procedure takes the start and stop dates that have been converted to week number values and fills in values for the WEEKLY LABOR STATUS, HOURS WORKED and DUAL JOB arrays for each week between stopping and starting dates that are passed to it.

In FILL, the WEELY LABOR STATUS array is loaded with either a survey year job number or a code signifying that there was not one civilian job that week (a code of 0, 2, 3, 4, 5, or 7). The DUAL JOB arrays are loaded with a survey year job number(s) if more than a civilian job is held that week; otherwise it is assigned a value of 0. The HOURS WORKED array is loaded with the number of hours worked on all jobs held that week, up to a maximum of 96 through 1992, and a maximum of 168 in subsequent years.

FILL is called from the CALC procedure for all start and stop dates except for military start and stop dates. Military start and stop dates are determined in the VARIABLES procedures for each year, and FILL is called from those procedures to fill in a code of 7 in the WEEKLY LABOR STATUS array for active military service.

Initially, FILL checks for valid start and stop dates. If the dates are valid, then FILL takes one of three paths. The first path is to evaluate the WEEKLY LABOR STATUS array for that week to see (1) if it contains a job number, (2) if the code passed from CALC is a job number, and (3) if the previous employer number for the job is different from the job number in the WEEKLY LABOR STATUS array. If all of these statements are true, then FILL determines that the job is not a duplication of the job that exists in the WEEKLY LABOR STATUS array for that week.

Next, FILL looks at the DUAL JOB arrays to see if there is a job number in a DUAL JOB array. If a DUAL JOB array already has a job number(s), then the current job number is compared to the DUAL JOB job number(s). If the job number does not exist in a DUAL JOB array, then the HOURSWEEK for that job is added to the number of hours for that week for the HOURS WORKED array and the job number is added to a DUAL JOB array. If the job is a duplicate job, then nothing is done to the arrays.

The second path is taken if there is no dual job and if the week dates are associated with a job or if there is not job number in the WEEKLY LABOR STATUS array. If this is the case, FILL tests for two conditions. The first condition is met if COD is 9. (A code of 9 means that the respondent had a period not working that was part OLF and part unemployed.) If COD equals 9, then the HOURSWEEK are subtracted from the hours in the HOURS WORKED array, because the respondent is not working at the job. The number of weeks unemployed (code of 4) is arbitrarily assigned to the middle portion of the weeks not working, and the rest of the period is determined to be OLF (code of 5).

The second condition in the second path tests to see if the value in the WEEKLY LABOR STATUS array is not a code of 4; if COD is a job number then the job number is placed into WEEKLY LABOR STATUS. If there are hours for the week and if the respondent was not working for the employer during this week, then the hours for the week are set to zero if the HOURS WORKED array is greater than zero. Otherwise, HOURS WORKED receives whatever value is in HOURSWEEK.

The third path FILL evaluates is if the week falls in a period not working and if there is a dual job. Then, the job number is deleted from the DUAL JOB arrays and HOURSWEEK for the job are subtracted from the HOURS WORKED array.

Finally, if there are more than four dual jobs in the DUAL JOB arrays then no other job numbers are added to the DUAL JOB arrays because the arrays accommodate up to four dual jobs.

Important information: Additional FILL procedure notes

A few last notes about FILL:

  1. Civilian work takes precedence over any other activity. If the respondent has a civilian job while in the military, then the civilian job code replaces the military code in the WEEKLY LABOR STATUS array.
  2. The order of precedence in the construction of the WEEKLY LABOR STATUS array after a civilian job is as follows:
    1. a code of 3, associated with an employer but periods not working with employer are missing; if any period not working is missing, then the entire period of the job is assigned a 3. In 1979, there are 274 cases with invalid period dates, and in each of the following survey years, there are fewer than 60 cases
    2. a code of 4, unemployed
    3. a code of 5, OLF
    4. a code of 2, period not working with employer, but OLF vs unemployed status is unknown
    5. a code of 7, active military service
    6. a code of 0, no information is reported to account for the week
  3. About 32 cases have a week in which JOB # 1 from a survey week first appears in the DUAL JOBS array rather than the WEEKLY LABOR STATUS array. This occurs when (1) there is a discrepancy between the date of the previous interview date as it appears on the info sheet that the interviewer uses at the time of the interview and the interview date recorded at the previous interview or (2) the starting date and ending date for a job across interview years are the same due primarily to the way the dates are floored and ceiled. In all these cases, an erroneous entry appears in the DUAL JOB array for that given week.

Changes to the Work History data

There have been a number of changes and updates to programs and input variables that are used to create the Work History data over the NLSY79 tenure. The most significant programming change was the conversion of the programming from PL/1 to equivalent SQL code. A list of the main NLSY79 variables used in the creation of the 1979-1996 work history data set is accessible at the end of this appendix.

Click below to view other changes and updates.

Changes between the 1979-86 and the 1979-87 Work History Data File

In 1987, a few changes were made to the program that created the work history data. These changes from the 1986 program affected the created labor force participation key variables, the WEEKLY LABOR STATUS array, and the HOURS WORKED array.

The following is a detailed discussion of the changes in the code that were made and the effects of those changes on the key variables and the week-by-week arrays:

  1. In the CALC PROC, the stop dates for all jobs and all periods not working were set to the interview date if the dates were greater than zero and if they were greater than the interview date. These changes resulted in an increased number of weeks unaccounted for in calculating weeks not working and in changes in the number of weeks unemployed and out of the labor force across all of the key variables for each survey year. Most of the changes were a difference of one week or a change to an invalid value.
  2. In the FILL PROC when hours were subtracted from the weekly HOURS WORKED array, a check was made to determine if the subtraction resulted in a value greater than or equal to zero. If it did not, the value in the HOURS WORKED array for that week was set to zero. If there was no dual job for that week, then the value in the HOURS WORKED array for that week was set to zero; previously, a subtraction was performed.
  3. Before these changes, some cases had negative hours (not including missing value codes) in some of the weeks in the HOURS WORKED array. Now, all of the values in the HOURS WORKED array are positive except for the standard missing values. These changes resulted in an overall decrease in the number of hours reported in a given week and in the number of hours calculated for the last calendar year and since the date of the last interview for those cases that were affected.

Note: The Work History Key Variable Cases Changed in 1987 Work History Program (PDF) contains a table listing the key variables for each year that had a change in values and the number of cases that had a change in the calculation of that key variable between the 1979-1987 work history creations and the previous years.

Changes between the 1979-1987 and the 1979-1988 Work History Data File

Most changes made to the work history program between the 1979-87 and 1979-88 releases did not affect the content of the variables themselves. Some changes were made to simplify the reading and use of the program in the future. Format changes were also made to allow for larger variable lengths. Because 1988 is the 10th year of the NLSY79, variables such as a job number, which provided only one space for the survey year, were expanded. The DUAL JOB array was no longer concatenated. Instead, four variables are created for each week in the array, allowing (as before) for up to four dual jobs per week.

Substantive changes are not major and are a function of changes in the questionnaire:

  • HOURSWEEK in 1988 also includes additional hours worked at home if any are reported. The 1988 questionnaire asked respondents separately about hours worked at home for a job. If any hours worked at home were reported, respondents were asked if their total hours worked per week included those hours worked at home. If not, the total hours worked per week and the hours worked at home were added together to get a total number of hours worked per week anywhere for a job.

Changes between the 1979-1988 and the 1979-1989 Work History Data File

A new set of variables was created in the 1979-89 work history program. These additions did not affect the content or substance of already existing variables.

  • A set of JOBSEVER variables was created from 1979-1989. These variables provide a cumulative count of the number of different jobs that have ever been reported by a respondent up to the date of interview for the survey year. Users should note that, as with calculations for the TENURE variables discussed earlier in this program description, employers can only be traced through contiguous years. In non-contiguous years, the number of jobs reported may be slightly inflated in some cases.

Some data changes were made in existing variables as well. Two of these reflect corrections that have been made in the calculations for 1987 and 1988 variables.

  1. The 1987-88 TENURE variables created by the 1979-87 and 1979-88 work history programs were in error. An error in the program statements which calculate this variable resulted in large numbers of respondents with valid values receiving -3 values instead. This error was corrected and the changes have been incorporated in subsequent releases.
  2. Beginning with the 1979-88 data release, the HOURSWEEK variable was created to include additional hours worked at home on a job, if reported. Although this was true for employers #6-10, the necessary programming changes for employers #1-5 were inadvertently omitted from the program. Therefore, employers #1-5 were calculated as they have been in previous work history programs, based upon one question without qualification for any additional hours worked at home. The omission was corrected.
  3. In 1988, 116 cases reported a 3rd within-job gap for at least one job. The information for these gaps was erroneously included as information for a 4th within-job gap. The 3rd within-job gaps for these cases would have been missing. This was corrected for the 1979-89 release. Additionally, information on a 4th within-job gap for at least one job was included for 18 cases.

Changes between the 1979-1989 and the 1979-1990 Work History Data File

A minor modification was made to the procedure which calculates the Hourly Rate of Pay (HRP#) from PAYRATE and TIMEUNIT). Starting in 1990, any PAYRATE with a value of 9999995 is set to -4 by the HRP procedure. This 9999995 value indicates a case for which the dollars and cents PAYRATE exceeded $100,000.00.

Some data updates were made to existing variables as well.

  1. Specific job information for 70 cases was edited, for one or more jobs, due to improper identification of CPS jobs in the Employer Supplements.
  2. Corrections were made to 23 cases for 1988 PAYRATES and/or 1988-1989 HOURLYWAGES. These cases exceeded $100,000.00 and should have been assigned the 9999995 value. While some contained that value, some retained an erroneous dollars and cents value in PAYRATE. In either case, the HOURLYWAGEs were calculated based upon an incorrect PAYRATE figure. The above-mentioned adjustment to HRP procedure will prevent the calculation of HOURLYWAGE figures from the truncated 9999995 value in the future.

Changes between the 1979-1991 and the 1979-1992 Work History Data File

A change has been made to the structure of the 1979-1992 work history data file on magnetic tape only. Due to the volume of the current work history data file, the data were split into two records. The first record contains the data for the STATUS, HOURS and DUALJOBS arrays. The second contains the remainder of the data, pertaining to specific job characteristics, gaps in employment and summary labor force activity variables. Those wishing to use only job specific variables can now do so without being required to process information for an entire case to do so. Those wishing to incorporate the arrays in analysis can access them in a separate record. Tape users should refer to the record layout and format table provided in this package of documentation for details on the exact location of each variable. This change does not affect the content or substance of already existing variables.

A correction was made to an existing set of variables as well. Users have already been notified of the inadvertent omission of hourly rates of pay for those respondent reporting earnings on a semi-monthly basis in the 1990 and 1991 main NLSY79 and work history data files, and in the Winter 1993 (No. 74) issue of NLSUPDATE. These cases have been corrected in the 1979-1992 version of the work history data file.

Changes between the 1979-1992 and the 1979-1993 Work History Data File

Beginning with the 1979-1993 release, the formats for the PAYRATE variables have been extended to 8 characters to accommodate values up to 99999999 ($999999.99). Previously, these cases containing these variables had been assigned a PAYRATE value of 9999995 and set to -4 in the HRP procedure, which creates the HOURLYWAGE variables. Valid PAYRATE and HOURLYWAGE values are now present in these cases.

Changes between the 1979-1993 and the 1979-1994 Work History Data File

The recall experiment (an experiment to test the recall of respondents over a two year period) was conducted with over 850 randomly selected respondents during the 1994 interview. For this experiment, respondents were treated as if the 1993 interview never took place; the interview was conducted as if the 1992 interview was the most recent. Because data from 1993 were already incorporated into the work history data, programmers sought to keep redundant data from the 1994 interview for the "recall" cases from overwriting the already incorporated 1993 data. Efforts were made to eliminate the overlap between the information reported in 1993 and 1994 for those cases, and to keep only the information from the 1994 interview that covered the period since the 1993 interview. However, there were isolated circumstances in which this was not possible. These relate to the assignment of "OLF" versus "unemployed" labor force status during periods not working which contain both types of statuses (see earlier discussion in this document). While it is possible to determine which part of a period not working occurred since the 1993 interview, it is not possible to make the same determination for "OLF" versus "unemployed" status during those periods. Therefore, it is likely that in some cases these statuses would not have been assigned correctly to certain periods not working. See Appendix 16 for further details on the recall experiment.

Changes between the 1979-1994 and the 1979-1996 Work History Data File

Through survey year 1994, the work history data was created by running PL/I programs on an IBM mainframe. In 1996, the volume of the work history data dictated a change to a more efficient method of production. To create the 1979-1996 data, the PL/I program was converted to a series of programs SQL code. Relevant variables from the main NLSY79 data were loaded into a relational data base, from which the work history data was generated. The SQL code that generated the data replicates the PL/I program, both in substance and function.

For respondents with missing interviews between the last interview and 1996, the WEEKLY LABOR STATUS, HOURS WORKED and DUAL JOB arrays were updated by the SQL program in the same manner as in past years with the PL/I programs.

Although the SQL programs are not included in this appendix, a separate addendum contains the PL/I programs from past years (see Work History PL/1 Programs). A list of the main NLSY79 variables used in the creation of the 1979-1996 work history data set is accessible at the end of this appendix.

Changes between the 1979-1996 and the 1979-1998 Work History Data File

Windows-based extraction software accompanied the 1979-1998 separate Work History data release for the first time.

The TENURE variable for job #2, reported in 1980, was found to be in error on the 1979-1996 work history release only. This variable was replaced with the correct data on the 1979-1998 work history release.

Changes between the 1979-1998 and the 1979-2000 Work History Data File

The 1979-2000 (round 19) combined public data release, marked the first time that the work history data was released in combination with the main NLSY79 data. Data items formerly available only in a separate work history data release, including the week-by-week arrays, were made available in a series of new areas of interest in the public release data set, using the same extraction software as the main NLSY79 data. This eliminated the need for multiple extracts and merging of data from different data sets, as well as the duplication of some information specific to individual jobs and respondents between data files.

The following areas of interest contain variables generated by the Work History programs that were formerly available only on the separate Work History release.

  • WORK HISTORY -- CALENDAR YEAR
  • WORK HISTORY -- DUAL JOB [1-4]
  • WORK HISTORY -- GAPS BETWEEN JOBS
  • WORK HISTORY -- HISTORY
  • WORK HISTORY -- HOURS WORKED
  • WORK HISTORY -- JOBS
  • WORK HISTORY -- MILITARY
  • WORK HISTORY -- SINCE LAST INTERVIEW
  • WORK HISTORY -- WEEKLY LABOR STATUS

Changes between the 1979-2000 and the 1979-2002 Work History Data File

The 1979-2002 (round 20) Employer Supplements underwent some significant revisions to better accommodate respondents reporting self-employed and non-traditional (temporary, contracting, on-call, etc.) types of employment situations, as well as teaching occupations. Many adjustments involved asking comparable or consistent questions with wording more appropriate to the type of employment being reported. These additional questions have been incorporated wherever necessary in the construction of the Work History data to produce variables consistent with those produced historically. Relevant question names are noted in the discussions below.

The 2000 Census Industry and Occupation Classifications were used to code the 2002 NLSY79 data. Prior to survey year 2002, industry and occupation data were coded using the 1970 codes, with 1980 codes being assigned to the current/most recent job for the respondent only.

Description and codes for variables in 1979-2022 NLSY79 Work History data

Below are discussions of three types of variables:

  • the weekly arrays created by the Work History programs
  • other items produced by the Work History programs
  • variables that are either used in the Work History programs, or are basic, commonly used job-specific survey items

Variable coding information, as well as formulas for combining job-specific characteristics from several sources, are included where relevant.

Work History weekly array variables

The foundation of the work history data is the set of week-by-week arrays depicting labor force status, total number of hours, and dual job holdings if any, for each week since January 1, 1978. These array variables are found in three areas of interest in the NLSY79 public release. The construction and coding for each of the three arrays are described below, listed by their area of interest.

Area of interest: WORK HISTORY-WEEKLY LABOR STATUS

The WEEKLY LABOR STATUS array is the work history week array. Each variable corresponds to a week relative to 1/1/78.[Note 1] There are 2385 variables in the 1979-2022 WEEKLY LABOR STATUS array--one for week #0 and one for each of the 2384 weeks from 1/1/78 to 09/03/2023.[Note 1] [Note 3] There are no missing data codes, and the codes that are in the array are as follows:

Table 1. Weekly Labor Status array codes

Code

Description

0

No information reported to account for week.

2

Not working (unemployment vs. out of the labor force cannot be determined.)

3

Associated with an employer but the periods not working for the employer are missing. If all of the time with the employer cannot be accounted for, a 3 is loaded into the STATUS array instead of a job code.

4

Unemployed. If a respondent is not working and part of the time is spent looking for work or on layoff, the exact weeks spent looking for work is unknown. As a result, the number of weeks spent looking is assigned to the middle part of the period not working.

5

Out of the labor force.

7

Active military service. If a respondent has a civilian job while in active military service, the civilian job code is loaded into the array instead of a code of 7.

>100

Worked. The code represents the appropriate work history year multiplied by 100 plus the job number for that employer in that year. For example, 102=year 1, job 2; 305=year 3, job 5. This allows one to associate any characteristic for a job with that week. If a respondent has more than one job at the same time, the job number that is loaded into the array is determined by the starting date of the job with the lowest job number, not by any particular characteristics of the job such as the number of hours worked at the job. The year in the job code is the year in which the job is reported. Jobs held in year 2, but reported in year 10 would be assigned job numbers beginning with 1001 instead of 201.

Important information: OLF and unemployed

In some cases, a respondent reports a period not working that is part OLF and part unemployed. In these cases, a week-specific distinction between OLF and unemployed cannot be made. Users should refer to the Work History Program Description in this appendix for a discussion of how OLF and unemployed codes are assigned to the WEEKLY LABOR STATUS array in the event that such a period occurs.

Area of interest: WORK HISTORY-HOURS WORKED

The HOURS WORKED array contains the usual hours worked per week at all jobs. There are 2385 variables in the 1979-2022 HOURS WORKED array--one for week #0 and one for each of the 2384 weeks from 1/1/78 to 09/03/2023.[Note 3] The codes are as follows:

Table 2. Hours Worked array codes

Code

Description

0

No hours worked or interview does not cover array week

1-95

Usual hours worked per week

96

96 or more hours per week

-5

Noninterview

-4

Valid skip

-3

Invalid skip

-2

Don't know

-1

Refusal

Important information: Max hours allowed

Beginning in 1993, the first all-CAPI survey year, the maximum hours allowed per week is 168.

Area of interest: WORK HISTORY-DUAL JOB 1-4

The DUAL JOB arrays contain job numbers for any weeks when the respondent worked at more than one job simultaneously. There can be up to 2385 variables in each DUAL JOB [#] array -- one for week #0 and one for each of the 2384 weeks from 1/1/78 to 09/03/2023.[Note 1] [Note 3] DUAL JOB array variables are present if a dual job was reported.[Note 2]

The codes are as follows:

Table 3. Dual Job array codes

Code

Description

0

No dual job

>100

Dual job year and job number

For example, if a respondent worked at three jobs at the same time, the code for the lowest job number would be in the WEEKLY LABOR STATUS array, and the codes for the other two jobs would be in the DUAL JOB arrays (see below). If the three jobs that the respondent held during week 190 from the 1981 (round 3) survey were jobs 1, 5, and 6, then WEEKLY LABOR STATUS would contain the value '301' for that week, the DUAL JOB 1 array for week 190 would contain the value '305' and the DUAL JOB 2 array for week 190 would contain '306'.

Important information: Additional dual job notes

  1. The maximum number of dual jobs accounted for is 4. The variable descriptions for variables in the WORK HISTORY - DUAL JOB [#] areas of interest indicate the relevant job number and week.
  2. The DUAL JOB [#] arrays do not provide labor force status in the detailed manner of the WEEKLY LABOR STATUS array. They contain only second, third, fourth, and fifth job numbers for weeks in which the respondent reports more than one employer.
  3. Users should be aware that it is possible in survey years 1979-1992 for the CPS job number to appear in one of the DUAL JOB [#] arrays instead of the WEEKLY LABOR STATUS array, as would be expected. In most cases, the CPS job will be the lowest number job for a given year. However, this is not always the case. Each year contains a relatively small number of cases for which JOB #1 is not the CPS job. For these cases, the job number assigned by the work history program will not necessarily be the lowest one for that year. In cases for which the CPS job is not held simultaneously to any other job, the job number for the CPS job will appear in the WEEKLY LABOR STATUS array as expected. However, in cases for which the CPS job is held simultaneously with another job with a lower job number, the possibility exists that the job number for the CPS job will appear in one of the DUAL JOB [#] arrays instead of the WEEKLY LABOR STATUS array. Mechanical changes implemented in the 1993 CAPI instrument to ensure that the CPS job is always the first job have virtually eliminated this possibility from 1993 forward.

Work History non-weekly array created

Non-weekly array variables produced by the work history programs are listed below by area of interest. Variables marked with an asterisk (*) contain an actual consecutive week number, ranging from week #0-2384, with the week of January 1, 1978, being week #1. Week #0 represents information for time prior to that date.

Area of interest: TIME & TENURE W/EMPLOYER

Table 4. Work History: Main Created variables
Question Name Variable Title
TENURE[#] Total weeks tenure at each job as of interview date

Area of interest: WORK HISTORY-MAIN-CREATED

Table 5. Work History: Main Created variables
Question Name Variable Title
MILWK-SLI Weeks of active military service since date of last interview
WKSWK-SLI Number of weeks worked since date of last interview
HRSWK-SLI Number of hours worked since date of last interview
WKSUEMP-SLI Number of weeks unemployed since date of last interview
WKSOLF-SLI Number of weeks out of the labor force since date of last interview
WKSUNACCT-SLI Percentage of weeks unaccounted for in calculating weeks worked since date of last interview
MILWK-PCY Weeks of active military service in past calendar year
WKSWK-PCY Number of weeks worked in past calendar year
HRSWK-PCY Number of hours worked in past calendar year
WKSUEMP-PCY Number of weeks unemployed in past calendar year
WKSOLF-PCY Number of weeks out of the labor force in past calendar year
WKSUNACCT-PCY Percentage of weeks unaccounted for in calculating weeks worked in past calendar year
WKSSINCELI (see also KEY Variables) Number of weeks since date of last interview
JOBSNUM Number of jobs ever reported as of interview date

Area of interest: KEY VARIABLES

Table 6. Work History: Key variables
Question Name Variable Title
WKSSINCELI (see also WORK HISTORY-MAIN-CREATED) Number of weeks since date of last interview

Area of interest: Earnings

Table 7. Work History: Earnings variable
Question Name Variable Title
HRP[#] Usual wage earned at each job converted to an hourly rate

Area of interest: WORK HISTORY-HISTORY

Table 8. Work History: History variables
Question Name Variable Title
LASTINT_WK#_[YEAR]* Week of last interview
CURRINT_WK#_[YEAR]* Week of current interview

Area of interest: WORK HISTORY-CALENDAR YEAR

Table 9. Work History: Calendar Year variables
Question Name Variable Title
CAL_YEAR_JOB[#]_[YEAR] Job number that is loaded into the WEEKLY LABOR STATUS array for each job. The 1st two digits of the number are the survey year (01 thru 30) and the 2nd two digits are the job for that year (job 01 thru 10)
CAL_YEAR_JOBS_[YEAR] Number of jobs in past calendar year
WKS_NWMISSC_[YEAR] Percentage of weeks not employed in past calendar year that cannot be split between unemployed and out of the labor force

Area of interest: WORK HISTORY-JOBS

Table 10. Work History: Jobs variables
Question Name Variable Title
START_WK#_[YEAR]_JOB#[##] Starting week of each job
STOP_WK#_[YEAR]_JOB#[##] Stopping week of each job
PER[#]_START_[YEAR]_JOB#[##] Starting week of each period not working for each job
PER[#]_STOP_[YEAR]_JOB#[##] Stopping week of each period not working for each job
PREV_EMP#_[YEAR]_JOB#[##] Previous job number at last interview for each job
JOB_NUM_A_[YEAR]_JOB#[##] Job number in STATUS array for each job

Area of interest: WORK HISTORY-GAPS BETWEEN JOBS

Table 11. Work History: Gaps Between Jobs variables
Question Name Variable Title
BSTART_[YEAR]_PERIOD[#] Week started each period not working between jobs
BSTOP_[YEAR]_PERIOD[#] Week stopped each period not working between jobs.

Area of interest: WORK HISTORY-SINCE LAST INTERVIEW

Table 12. Work History: Since Last Interview variables
Question Name Variable Title
LASTINT_#JOBS_[YEAR] Number of jobs since the date of the last interview
WKS_NWMISSL_[YEAR] Percentage of weeks not employed since the date of the last interview that cannot be split between unemployed and out of the labor force

Area of interest: WORK HISTORY-MILITARY

Table 13. Work History: Military variables
Question Name Variable Title
MIL_START1_[YEAR] Starting week of first period of active military service.
MIL_START2_[YEAR] Starting week of second period of active military service.
MIL_STOP1_[YEAR] Stopping week of first period of active military service.
MIL_STOP2_[YEAR] Stopping week of second period of active military service.

NLSY79 main data Work History variables

A third set of variables are either used in the Work History programs, or are basic, commonly used job-specific and gap-related survey items. These items are enumerated in "Work History Job and Gap-specific Survey Items (2022)" section below, click to view details.

The separate Work History data files released prior to survey year 2000 contained a large number of duplicated items pertaining to jobs, job gaps, and the individual respondents that were copied straight from the main data file. In the public data releases in 2000 and subsequent years, these items can be found in their traditional place among public release data items. They are listed below by type of variable. Example QNAMES for the most current survey year for each variable are listed in parentheses. The variable names each was assigned in 1979-1994 PL/I programs are listed in parentheses. The SAS and SQL programs that use the items in the table below to compute inputs for and create the Work History variable outputs can be found the Variables used in creation of 1996 and subsequent Work History data file section below.

Type Question Name Description
Respondent Variables PUBLIC ID Respondent's public identification code
SAMPLE_SEX (SEX) Respondent's sex
SAMPLE_RACE (RACE) Respondent's race
SAMPLE_ID (SAMPLE_ID) Respondent's sample type
Q1-3_A~M (BIRTHM_79) Respondent's month of birth from the 1979 interview.
Q1-3_A~Y (BIRTHY_79) Respondent’s year of birth from the 1979 interview.
Q1-3_A~M (BIRTHM_81) Respondent's month of birth from 1981 interview or from 1979 interview if 1981 non-interview
Q1-3_A~Y (BIRTHY_81) Respondent's year of birth from 1981 interview or from 1979 interview if 1981 non-interview
Survey year variables (data present for each survey year) SAMPWEIGHT (WEIGHT) Sampling weight
CURDATE~M (INTM) Date of interview - Month
CURDATE~Y (INTY) Date of interview - Year
Job variables (data present for up to 5 jobs for each survey year) EMPLOYER_STARTDATE.##~M (STARTM) Starting month of job
EMPLOYER_STARTDATE.##~Y (STARTY) Starting year of job
EMPLOYER_STOPDATE.##~M (STOPM) Stopping month of job
EMPLOYER_STOPDATE.##~Y (STOPY) Stopping year of job
QES-4A.## & QES-4B.## (PAST) Starting date of each job is before, the same as, or after the date of the last interview?
*Combination of two variables in CAPI interviews
QES-23.## (CURRENT) Currently working for employer at date of interview
QES-23A.## (WHYLEFT) Reason left job
*Please note that coding varies over time
EMPLOYER_CPSFLAG.## (CPSJOB) Is employer the CPS employer? In other words, is employer the current or most recent employer?
*This variable is all -4's for 1979, when job 1 is the CPS job. Beginning in 1993, job #1 is always the CPS job if there is one.
OCCALL-EMP.## (OCCUPATION) Kind of work usually done for employer - 1970 codes through survey year 2000, 2000 codes thereafter.
INDALL-EMP.## (INDUSTRY) Kind of business or industry of employer - 1970 codes through survey year 2000, 2000 codes thereafter
COWALL-EMP.## (CLASSWORKER) Employee of a private company, a government employee, self-employed, or working without pay at a family business or farm of worker at each job?
*Please note coding changes beginning in 1994
QES-51.## (HOURDAY) Hours per day usually worked at job
PAYRATE-ALL-EMP.## (PAYRATE) How much usually earned at job
QES-71A.## (TIMERATE) Pay rate reported per hour, per day, per week, or what at job
QES-88B.## (UNION) Wages or salary at each job set by a collective bargaining agreement between employer and a union or employee association?
*Please note restriction on hours per week working varies over time
QES-22.## (GOVTJOB)* Is one or more of government job codes circled on the cover of employer supplement? In other words, is job a government-sponsored job?
*Question eliminated in 1988
QES-28.## (WEEKSNOTWORKED) Between start and stop dates for each job for each year, were there any periods of a full week or more during which R did not work for employer, not counting paid vacations or paid sick leave?
QES-6.## (PRETEN) The total number of months worked for employer before date of last interview
Gaps within jobs (data present for up to 4 gaps within each job for each survey year) QES-33.## (REASON) Reason not working for employer for each period not working
QES-36.## (ALL) How many weeks looking for work or on layoff during each period not working?
QES-41.## (LOOK) Number of weeks not working or looking for work or on layoff during each period not working
Gaps between jobs (data present for up to 6 gaps between jobs for each survey year) Q7-12.## (BALL) How many weeks not working spent looking for work or on layoff during periods not working between jobs?
Q7-16.## (BLOOK) Number of weeks looking for work or on layoff during periods not working between jobs
Q7-19.## (BREASON) Reason not looking for work during periods not working between jobs

Variables compiled from NLSY79 main data variables A small set of variables in the pre-2000 separate work history data files were created from multiple variables in the main data. They are listed below, along with the items that were used to compile them in the most recent year available.

Question Name Description
  • QES-52A.##*
  • HOURS_WORKED_WEEK_ALL.##
  • (HOURSWEEK)**

Hours per week usually worked at each job

*Variables exist through 2012 survey year.
**Beginning in 1988 this variable includes additional hours worked at home if any are reported

  • EMPLOYER_EMPPREVID.##
  • (PREVIOUSEMP#)

Job number assigned to employer from last interview as listed on information sheet for each interview year. This allows for matching employers between consecutive interview years only.

See Appendix 9: Linking Employers Through Survey Years for a more detailed discussion.

Variables used in creation of 1996 and subsequent Work History data file

Beginning in 1996, the work history programming was converted to SQL programming. The SQL programs, which mirror the older PL/1 program run prior to 1996, are available by accessing the "Work History SQL Variable Creation Programs" section below. Programs that create the input variables for the Work History SQL programs can be accessed in the "Work History Inputs Creation Programs" section below.

Click to view programming code.

Employer Data Table Variables

EMPLOYER, PUBID,  JOBSTWHN, MNSB4DLI, CURWKEMP, YLEFTJOB, ANYWJGAP, STAJOBCM, STAJOBCD, STAJOBCY,  STOJOBM, STOJOBD, STOJOBY, STAWGP1M,  STAWGP1D, STAWGP1Y, STOWGP1M, STOWGP1D,  STOWGP1Y, STAWGP2M, STAWGP2D, STAWGP2Y, STOWGP2M, STOWGP2D, STOWGP2Y, STAWGP3M, STAWGP3D, STAWGP3Y, STOWGP3M, STOWGP3D, STOWGP3Y, STAWGP4M, STAWGP4D, STAWGP4Y, STOWGP4M,  STOWGP4D, STOWGP4Y, YNWKWG11, YNWKWG1C, WKLKWG11, WKLKWG12, YNWKWG21, YNWKWG2C, WKLKWG21, WKLKWG22, YNWKWG31, YNWKWG3C, WKLKWG31, WKLKWG32, YNWKWG41, YNWKWG4C, WKLKWG41, WKLKWG42, HRSDAYU, HRSWKU, HRSWKUHM, HRSWK, OCCSMDLI, ROPTU, HRROP1, HRROP2, HRROP3, HRROP4, HRROP5, WKROP1, WKROP2, WKROP3, WKROP4, WKROP5, WKROP6, MOROP1, MOROP2, MOROP3, MOROP4, MOROP5, MOROP6, YRROP1, YRROP2, YRROP3, YRROP4, YRROP5, YRROP6, BWROP1, BWROP2, BWROP3, BWROP4, BWROP5, BWROP6, PAYRATE, UNIONJOB, PREVID, IND, OCC, COW

Gaps Data Table Variables

SURVYR, PUBID, STABGPM1, STABGPD1, STABGPY1, STOBGPM1, STOBGPD1, STOBGPY1, WKLKBG11, WKLKBG12, YNOLKB1G, STABGPM2, STABGPD2, STABGPY2, STOBGPM2, STOBGPD2, STOBGPY2, WKLKBG21, WKLKBG22, YNOLKB2G, STABGPM3, STABGPD3, STABGPY3, STOBGPM3, STOBGPD3, STOBGPY3, WKLKBG31,WKLKBG32, YNOLKB3G, STABGPM4, STABGPD4, STABGPY4, STOBGPM4, STOBGPD4, STOBGPY4, WKLKBG41, WKLKBG42, YNOLKB4G, STABGPM5, STABGPD5, STABGPY5, STOBGPM5, STOBGPD5, STOBGPY5, WKLKBG51, WKLKBG52, YNOLKB5G, STABGPM6, STABGPD6, STABGPY6, STOBGPM6, STOBGPD6, STOBGPY6, WKLKBG61, WKLKBG62, YNOLKB6G

Newyear Data Table Variables

SURVYR, PUBID, NORCID, WEIGHT, CURINTMO, CURINTDA, CURINTYR, LINTMO, LINTDAY, LINTYR, MILOUTLI, MILINLI, AMILCRLI, MILOUTM1, MILOUTD1, MILOUTY1, MILSINLI, MLSINLI2, MLSINLI3, MLSINLI4, MLSINLI5, CRMLSNLI, AMILSNLI, MILINM1, MILIND1, MILINY1, SRVACTML, Q4_12A, MILINM2, MILIND2, MILINY2, MILINM3, MILIND3, MILINY3, MILOUTM2, MILOUTD2, MILOUTY2, MILOUTM3, MILOUTD3, MILOUTY3, ACTMLNOW, MILSTDLI

01_INITARRAYS.SQL

set serveroutput on
DECLARE
max_wk number(5);
max_master_wk number(5);
BEGIN
SELECT MAX(wk_num) INTO max_wk FROM datadba.weeks;
SELECT MAX(endwk)  INTO max_master_wk FROM datadba.master_weeks;
DBMS_OUTPUT.PUT_LINE('PREV MAX WEEK# (from datadba.weeks)         : ' || TO_CHAR(max_wk));
DBMS_OUTPUT.PUT_LINE('NEW MAX WEEK#  (from datadba.master_weeks)  : ' || TO_CHAR(max_master_wk));
 FOR n IN 1..12686 LOOP
  FOR i IN max_wk+1..max_master_wk LOOP  /* 104 weeks+2 extra just in case*/
  INSERT INTO datadba.weeks VALUES (n,i,0,0);
  END LOOP;
 COMMIT;
 END LOOP;
END;
/
exit;

02_HISTORY.SQL

set serveroutput on;
delete from datadba.history where round=30;
DECLARE
      max_value INTEGER;
      var_pubid   INTEGER;
      month  NUMBER (2);
      day    NUMBER (2);
      year   NUMBER (4);
      leap   NUMBER (5,2);
      days_month INTEGER;
      temp_weight INTEGER;
      max_lintwk INTEGER;
      wk_num  NUMBER (7,2);
      CURSOR id_cursor IS
                       SELECT pubid
                       from datadba.newyear_data order by pubid;
BEGIN
      OPEN id_cursor;
      LOOP
          FETCH id_cursor INTO var_pubid;
          EXIT WHEN id_cursor%NOTFOUND;
          SELECT weight, curintmo, curintda, curintyr 
              INTO temp_weight, month,day,year
              FROM datadba.newyear_data
              WHERE pubid=var_pubid;
           
          SELECT MAX(round), MAX(currint_wk#)
          INTO max_value, max_lintwk FROM datadba.history
          WHERE public_id=var_pubid;
          max_value :=max_value + 1;
          max_lintwk :=max_lintwk+1;
          IF temp_weight = 0 THEN
             INSERT INTO datadba.history 
             VALUES (var_pubid, max_value, 0, -5, -5, -5, -5, -5);
             GOTO nextcase;
          END IF;
          leap:=0;
          IF year<=99 THEN DBMS_OUTPUT.PUT_LINE('HALT !!! NON Y2K YEAR'); END IF;
          IF year>=1980 THEN
            leap:=CEIL((year-1980)/4);
          END IF;
          IF MOD(year,4)=0 AND month>2 THEN
             leap:=leap+1;
          END IF;
          IF month=1 THEN
            days_month:=0;
          END IF;
          IF month=2 THEN
             days_month:=31;
          END IF;
          IF month=3 THEN
            days_month:=59;
          END IF;
          IF month=4 THEN
            days_month:=90;
          END IF;
          IF month=5 THEN
            days_month:=120;
          END IF;
          IF month=6 THEN
             days_month:=151;
          END IF;
          IF month=7 THEN
             days_month:=181;
          END IF;
          IF month=8 THEN
            days_month:=212;
          END IF;
          IF month=9 THEN
             days_month:=243;
          END IF;
          IF month=10 THEN
             days_month:=273;
          END IF;
          IF month=11 THEN
             days_month:=304;
          END IF;
          IF month=12 THEN
            days_month:=334;
          END IF;
     
          wk_num:=FLOOR(((year-1978) *365 + days_month + day + leap)/7);
          INSERT INTO datadba.history VALUES 
             (var_pubid, max_value, temp_weight, max_lintwk, wk_num, 
              month,day,year);
          <<nextcase>>
          COMMIT;           
      END LOOP;  
      CLOSE id_cursor;
END;    
/
exit;

03_JOBS.SQL

delete from datadba.jobs where round=30;
delete from datadba.error_tab;
set serveroutput on format wrapped;
set echo off;
set tab off;
set linesize 4000;
DECLARE  -- variables declared used within the program.
      temp_number  NUMBER (4);
      max_value    INTEGER;
      var_pubid    INTEGER;
      month        NUMBER (2);
      day          NUMBER (2);
      year         NUMBER (4);
      leap         NUMBER (4);
      days_month   INTEGER;
      wk_num       NUMBER (6);
      wk_num_stop  NUMBER (6);
      month_stop   NUMBER (2);
      day_stop     NUMBER (2);
      year_stop    NUMBER (4);
      leap_stop    NUMBER (4);
      days_month_stop  INTEGER;
      var_weight    INTEGER;
      var_curintmo  NUMBER (2);
      var_curintda  NUMBER (2);
      var_curintyr  NUMBER (4);
      var_lintmo    NUMBER (2);
      var_lintday   NUMBER (2);
      var_lintyr    NUMBER (4);
      var_actmlnow  NUMBER (2);
      var_stajob1m  NUMBER (2); /* Nagi drops these 1/2001 */
      var_stajob1d  NUMBER (2); /* Nagi drops these 1/2001 */
      var_stajob1y  NUMBER (4); /* Nagi drops these 1/2001 */
      var_stajob2m  NUMBER (2); /* Nagi drops these 1/2001 */
      var_stajob2d  NUMBER (2); /* Nagi drops these 1/2001 */
      var_stajob2y  NUMBER (4); /* Nagi drops these 1/2001 */
      var_job_num_a NUMBER (4);
      var_tenure    NUMBER (4);
      var_cps       NUMBER (2);
      var_stawgp1m  NUMBER (2);
      var_stawgp1d  NUMBER (2);
      var_stawgp1y  NUMBER (4);
      var_stowgp1m  NUMBER (2);
      var_stowgp1d  NUMBER (2);
      var_stowgp1y  NUMBER (4);
      var_stawgp2m  NUMBER (2);
      var_stawgp2d  NUMBER (2);
      var_stawgp2y  NUMBER (4);
      var_stowgp2m  NUMBER (2); 
      var_stowgp2d  NUMBER (2); 
      var_stowgp2y  NUMBER (4);
      var_stawgp3m  NUMBER (2);
      var_stawgp3d  NUMBER (2); 
      var_stawgp3y  NUMBER (4);
      var_stowgp3m  NUMBER (2);
      var_stowgp3d  NUMBER (2);
      var_stowgp3y  NUMBER (4);
      var_stawgp4m  NUMBER (2);
      var_stawgp4d  NUMBER (2);
      var_stawgp4y  NUMBER (4);
      var_stowgp4m  NUMBER (2);
      var_stowgp4d  NUMBER (2);
      var_stowgp4y  NUMBER (4);
      var_start     NUMBER(5);
      var_stop      NUMBER(5);
      var_job#      NUMBER (4);
      var_period    NUMBER (1);
      var_number    NUMBER (4);
      var_past      NUMBER (3);
      past_tenure   INTEGER;
      temp_maxvalue NUMBER (3);
      var_stajobcm  NUMBER (2);
      var_stajobcd  NUMBER (2);
      var_stajobcy  NUMBER (4);
      var_stojobm   NUMBER (2);
      var_stojobd   NUMBER (2);
      var_stojoby   NUMBER (4);
      var_payrate1  NUMBER (10);
      var_payrate2  NUMBER (10);
      var_payrate3  NUMBER (10);
      var_payrate4  NUMBER (10);
      var_payrate5  NUMBER (10);
      var_payrate6  NUMBER (10);
      var_payrate7  NUMBER (10);
      var_payrate8  NUMBER (10);
      var_payrate9  NUMBER (10);
      var_payrate10 NUMBER (10);
      var_anywjgap  NUMBER (1); 
      var_roptu     NUMBER (3);
      var_hrsdayu   NUMBER (2);
      var_hrswku    NUMBER (4);
      hrly_wage     NUMBER (8);
      var_hrswk1    NUMBER (3);
      var_previd    NUMBER (2);
      var_preten    NUMBER (4);
      var_per1_start NUMBER (4);
      var_per1_stop  NUMBER (4);
      var_per1_reason  NUMBER (2);
      var_per1_all   NUMBER (3);
      var_per1_look  NUMBER (3);
      var_per2_start NUMBER (4);
      var_per2_stop  NUMBER (4);
      var_per2_reason  NUMBER (2);
      var_per2_all   NUMBER (3);
      var_per2_look  NUMBER (3);
      var_per3_start NUMBER (4);
      var_per3_stop  NUMBER (4);
      var_per3_reason  NUMBER (2);
      var_per3_all   NUMBER (3);
      var_per3_look  NUMBER (3);
      var_per4_start NUMBER (4);
      var_per4_stop  NUMBER (4);
      var_per4_reason  NUMBER (2);
      var_per4_all   NUMBER (3);
      var_per4_look  NUMBER (3); 
      var_curwkemp   NUMBER (3);
      var_yleftjob   NUMBER (3);
      var_hrswk      NUMBER (4);
      var_occ        NUMBER (4);
      var_ind        NUMBER (4);
      var_cow        NUMBER (4);
      var_unionjob   NUMBER (4);
      kount          INTEGER;
      err_num        NUMBER;
      err_msg        VARCHAR2(100);
      CURSOR id_cursor IS 
                    SELECT pubid,weight,curintmo,curintda,curintyr,
                           lintmo,lintday,lintyr,actmlnow
                    FROM datadba.newyear_data order by pubid;
      FUNCTION wk_number (month NUMBER, day NUMBER, year NUMBER)RETURN NUMBER IS
        wk_num     NUMBER(7,2);
        leap       NUMBER (7,3);
        days_month NUMBER (3);
        rday       NUMBER(3);
      BEGIN
        rday:=day;
        IF day<=0 THEN rday:=15; END IF;
        IF month =-1 OR year =-1 THEN
          RETURN -1;
        ELSIF month =-2 OR year =-2 THEN
          RETURN -2; 
        ELSIF month =-3 OR year =-3 THEN
          RETURN -3; 
        ELSIF month <=0 OR year <=0 THEN
          RETURN -4;
        ELSIF year > 1900 AND year < 1978 THEN 
          RETURN 0;
        END IF;  
        leap:=0;
        IF year <=99 THEN 
          DBMS_OUTPUT.PUT_LINE('HALT !!! DATE ^ Y2K !!!'); 
          RETURN (0);
        END IF;
        IF year>=1980 THEN
           leap:=CEIL((year-1980)/4);
        END IF;
        IF MOD(year,4)=0 AND month>2 THEN
           leap:=leap+1;
        END IF;
        IF month=1 THEN
          days_month:=0;
        END IF;
        IF month=2 THEN
            days_month:=31;
        END IF; 
        IF month=3 THEN
          days_month:=59;
        END IF;
        IF month=4 THEN
          days_month:=90;
        END IF;
        IF month=5 THEN
          days_month:=120;
        END IF;
        IF month=6 THEN
          days_month:=151;
        END IF;
        IF month=7 THEN
          days_month:=181;
        END IF;
        IF month=8 THEN
           days_month:=212;
        END IF;
        IF month=9 THEN
          days_month:=243;
        END IF;
        IF month=10 THEN
           days_month:=273;
        END IF;
        IF month=10 THEN
          days_month:=273;
        END IF;
        IF month=11 THEN
           days_month:=304;
        END IF;
        IF month=12 THEN
        days_month:=334;
         END IF;
        wk_num:=((year-1978) *365 + days_month + rday + leap)/7;
        RETURN(wk_num);
      END wk_number;
BEGIN
DBMS_OUTPUT.ENABLE(10000);
       SELECT MAX(round) INTO max_value FROM datadba.jobs;
        max_value:=max_value + 1;
           
     kount:=0;
     OPEN id_cursor;
      LOOP
        <<nextcase>>
        FETCH id_cursor INTO var_pubid,var_weight,
                        var_curintmo,var_curintda,var_curintyr,
                        var_lintmo,var_lintday,var_lintyr,var_actmlnow;
        EXIT WHEN id_cursor%NOTFOUND;   
/*         EXIT WHEN id_cursor%ROWCOUNT=20; */
        IF var_weight=0 THEN GOTO nextcase;  END IF;
/**************************EMPLOYER #1-10 ********************************/
         FOR f IN 1..10 LOOP
          SELECT curwkemp, stajobcm, stajobcd, stajobcy 
          INTO var_curwkemp, var_stajobcm, var_stajobcd, var_stajobcy
          FROM datadba.emp_supplement
          WHERE pubid=var_pubid AND employer=f;
          EXIT WHEN var_curwkemp=-4;
          IF var_stajobcm=-4 AND var_stajobcd=-4 AND var_stajobcy=-4 THEN
             var_job_num_a:=-4;
          END IF;
          IF var_stajobcm>=-3 AND var_stajobcd>=-3 AND var_stajobcy>=-3 AND 
                 var_actmlnow^=1 AND f=1
                 THEN  var_cps:=1;   /*CPS JOB ASSUMED TO BE IN ES1 IN CAPI*/
          ELSE var_cps:=0;
          END IF;
/*calculate the start week number of the job */ 
        IF CEIL(wk_number(var_stajobcm,var_stajobcd,var_stajobcy))<0 THEN
           var_start:=CEIL(wk_number(var_stajobcm,var_stajobcd,var_stajobcy));          
         ELSIF CEIL(wk_number(var_stajobcm,var_stajobcd,var_stajobcy))=
           FLOOR(wk_number(var_stajobcm,var_stajobcd,var_stajobcy)) THEN
           var_start:=CEIL(wk_number(var_stajobcm,var_stajobcd,var_stajobcy))+1;
         ELSE var_start:=CEIL(wk_number(var_stajobcm,var_stajobcd,var_stajobcy));
        END IF;
/* calculate stop week */
          SELECT stojobm, stojobd, stojoby INTO var_stojobm,var_stojobd,var_stojoby
          FROM datadba.emp_supplement
          WHERE pubid=var_pubid and employer=f;
          var_stop:=CEIL(wk_number(var_stojobm,var_stojobd,var_stojoby));
          IF var_stojobm=var_curintmo AND var_stojobd=var_curintda AND
             var_stojoby=var_curintyr THEN                  
             var_stop:=FLOOR(wk_number(var_stojobm,var_stojobd,var_stojoby));
          END IF;
/*compute hourly wage */
           SELECT roptu, hrsdayu, payrate, hrswk, hrswku 
             INTO var_roptu, var_hrsdayu, var_payrate1, var_hrswk1, var_hrswku
           FROM datadba.emp_supplement
           WHERE pubid=var_pubid and employer=f;
           IF var_payrate1>0 AND var_roptu>0 THEN 
             IF var_roptu=1 THEN hrly_wage:=var_payrate1;
               ELSIF(var_roptu=2 OR var_roptu=3 or var_roptu=7) AND var_hrswk1>0
                   THEN hrly_wage:=FLOOR(var_payrate1/var_hrswk1);
                 ELSIF var_roptu=4 AND var_hrswk1>0 
                     THEN hrly_wage:=FLOOR(var_payrate1/(var_hrswk1 * 2));
                   ELSIF var_roptu=5 AND var_hrswk1>0
                       THEN hrly_wage:=FLOOR(var_payrate1/(var_hrswk1 * 4.3));
                     ELSIF var_roptu=6 AND var_hrswk1>0
                         THEN hrly_wage:=FLOOR(var_payrate1/(var_hrswk1 * 52));
                       ELSIF var_roptu=8 AND var_hrswk1>0
                           THEN hrly_wage:=FLOOR(var_payrate1/(var_hrswk1 * 2.15));
                        ELSE hrly_wage:=-4;
             END IF;
           ELSE hrly_wage:=-4;
           END IF;
/* calculate periods not working*/
               SELECT anywjgap INTO var_anywjgap FROM datadba.emp_supplement
               WHERE pubid=var_pubid and employer=f;
               IF var_anywjgap=1 THEN 
                 SELECT stawgp1m, stawgp1d, stawgp1y, stowgp1m, stowgp1d, stowgp1y, 
                        stawgp2m, stawgp2d, stawgp2y, stowgp2m, stowgp2d, stowgp2y, 
                        stawgp3m, stawgp3d, stawgp3y, stowgp3m, stowgp3d, stowgp3y, 
                        stawgp4m, stawgp4d, stawgp4y, stowgp4m, stowgp4d, stowgp4y 
                 INTO var_stawgp1m, var_stawgp1d, var_stawgp1y, var_stowgp1m, var_stowgp1d, var_stowgp1y, 
                      var_stawgp2m, var_stawgp2d, var_stawgp2y, var_stowgp2m, var_stowgp2d, var_stowgp2y, 
                      var_stawgp3m, var_stawgp3d, var_stawgp3y, var_stowgp3m, var_stowgp3d, var_stowgp3y, 
                      var_stawgp4m, var_stawgp4d, var_stawgp4y, var_stowgp4m, var_stowgp4d, var_stowgp4y 
                 FROM datadba.emp_supplement
                 WHERE pubid=var_pubid and employer=f;      
                 
                     IF var_stawgp1m>0 AND var_stawgp1d>0  AND var_stawgp1y>0 THEN
                       IF CEIL(wk_number(var_stawgp1m,var_stawgp1d,var_stawgp1y))=
                          FLOOR(wk_number(var_stawgp1m,var_stawgp1d,var_stawgp1y)) 
                          THEN var_per1_start:=
                          CEIL(wk_number(var_stawgp1m,var_stawgp1d,var_stawgp1y))+1;
                       ELSE var_per1_start:=
                          CEIL(wk_number(var_stawgp1m,var_stawgp1d,var_stawgp1y));
                       END IF;
                       IF var_per1_start>0 THEN 
                         SELECT ynwkwg1c, wklkwg11, wklkwg12 INTO var_per1_reason, var_per1_all, var_per1_look                         
                         FROM datadba.emp_supplement
                         WHERE pubid=var_pubid AND employer=f;
                       ELSE var_per1_reason:=-4; var_per1_all:=-4; var_per1_look:=-4;
                       END IF;
                       var_per1_stop:=CEIL(wk_number(var_stowgp1m,var_stowgp1d,var_stowgp1y));
                       IF var_stowgp1m=var_curintmo AND 
                          var_stowgp1d=var_curintda AND
                          var_stowgp1y=var_curintyr THEN                  
                       var_per1_stop:=FLOOR(wk_number(var_stowgp1m,var_stowgp1d,var_stowgp1y)); 
                       END IF;
                     END IF;
                     
                     IF var_stawgp2m>0 AND var_stawgp2d>0  AND var_stawgp2y>0 THEN
                       IF CEIL(wk_number(var_stawgp2m,var_stawgp2d,var_stawgp2y))=
                          FLOOR(wk_number(var_stawgp2m,var_stawgp2d,var_stawgp2y)) 
                          THEN var_per2_start:=
                          CEIL(wk_number(var_stawgp2m,var_stawgp2d,var_stawgp2y))+1;
                       ELSE var_per2_start:=
                          CEIL(wk_number(var_stawgp2m,var_stawgp2d,var_stawgp2y));
                       END IF;
                       var_per2_stop:=CEIL(wk_number(var_stowgp2m,var_stowgp2d,var_stowgp2y));
                       IF var_stowgp2m=var_curintmo AND 
                          var_stowgp2d=var_curintda AND
                          var_stowgp2y=var_curintyr THEN                  
                       var_per2_stop:=FLOOR(wk_number(var_stowgp2m,var_stowgp2d,var_stowgp2y)); 
                       END IF;
                       SELECT ynwkwg2c, wklkwg21, wklkwg22 INTO var_per2_reason, var_per2_all, var_per2_look 
                       FROM datadba.emp_supplement
                       WHERE pubid=var_pubid AND employer=f;
                     ELSE var_per2_start:=-4;
                          var_per2_stop:=-4;
                          var_per2_reason:=-4;
                          var_per2_all:=-4;
                          var_per2_look:=-4;
                     END IF;                  
                     IF var_stawgp3m>0 AND var_stawgp3d>0  AND var_stawgp3y>0 THEN
                       IF CEIL(wk_number(var_stawgp3m,var_stawgp3d,var_stawgp3y))=
                          FLOOR(wk_number(var_stawgp3m,var_stawgp3d,var_stawgp3y)) 
                          THEN var_per3_start:=
                          CEIL(wk_number(var_stawgp3m,var_stawgp3d,var_stawgp3y))+1;
                       ELSE var_per3_start:=
                          CEIL(wk_number(var_stawgp3m,var_stawgp3d,var_stawgp3y));
                       END IF;
                      var_per3_stop:=
                       CEIL(wk_number(var_stowgp3m,var_stowgp3d,var_stowgp3y));
                       IF var_stowgp3m=var_curintmo AND 
                          var_stowgp3d=var_curintda AND
                          var_stowgp3y=var_curintyr THEN                  
                       var_per3_stop:=FLOOR(wk_number(var_stowgp3m,var_stowgp3d,var_stowgp3y)); 
                       END IF;
                       SELECT ynwkwg3c, wklkwg31, wklkwg32 INTO var_per3_reason, var_per3_all, var_per3_look 
                       FROM datadba.emp_supplement
                       WHERE pubid=var_pubid AND employer=f;
                     ELSE var_per3_start:=-4;
                          var_per3_stop:=-4;
                          var_per3_reason:=-4;
                          var_per3_all:=-4;
                          var_per3_look:=-4;
                     END IF;
                     IF var_stawgp4m>0 AND var_stawgp4d>0  AND var_stawgp4y>0 THEN
                       IF CEIL(wk_number(var_stawgp4m,var_stawgp4d,var_stawgp4y))=
                          FLOOR(wk_number(var_stawgp4m,var_stawgp4d,var_stawgp4y)) 
                          THEN var_per4_start:=
                          CEIL(wk_number(var_stawgp4m,var_stawgp4d,var_stawgp4y))+1;
                       ELSE var_per4_start:=
                          CEIL(wk_number(var_stawgp4m,var_stawgp4d,var_stawgp4y));
                       END IF;
                      var_per4_stop:=CEIL(wk_number(var_stowgp4m,var_stowgp4d,var_stowgp4y));
                       IF var_stowgp4m=var_curintmo AND 
                          var_stowgp4d=var_curintda AND
                          var_stowgp4y=var_curintyr THEN                  
                       var_per4_stop:=FLOOR(wk_number(var_stowgp4m,var_stowgp4d,var_stowgp4y)); 
                       END IF;
                       SELECT ynwkwg4c, wklkwg41, wklkwg42  INTO var_per4_reason, var_per4_all, var_per4_look 
                       FROM datadba.emp_supplement
                       WHERE pubid=var_pubid AND employer=f;
                     ELSE var_per4_start:=-4;
                          var_per4_stop:=-4;
                          var_per4_reason:=-4;
                          var_per4_all:=-4;
                          var_per4_look:=-4;
                     END IF;
               ELSE var_per1_start:=-4; var_per1_stop:=-4; var_per1_reason:=-4; var_per1_all:=-4; var_per1_look:=-4; 
                    var_per2_start:=-4; var_per2_stop:=-4; var_per2_reason:=-4; var_per2_all:=-4; var_per2_look:=-4; 
                    var_per3_start:=-4; var_per3_stop:=-4; var_per3_reason:=-4; var_per3_all:=-4; var_per3_look:=-4; 
                    var_per4_start:=-4; var_per4_stop:=-4; var_per4_reason:=-4; var_per4_all:=-4; var_per4_look:=-4; 
               END IF;
/* calculate TENURE*/   
               IF var_start>=0 AND var_stop>=var_start THEN
                          var_tenure:=var_stop - var_start+1;
               ELSE var_tenure:=-3;
               END IF;
               IF var_tenure>0 THEN
               SELECT previd INTO var_previd FROM datadba.emp_supplement
                      WHERE pubid=var_pubid AND employer=f;
               IF var_previd=0 THEN var_previd:=-4; END IF;
               BEGIN     
                   IF var_previd>0 THEN 
                      SELECT MAX(round) INTO temp_maxvalue
                             FROM datadba.jobs WHERE public_id=var_pubid AND
                             round ^= max_value;
                      SELECT tenure INTO past_tenure FROM datadba.jobs
                             WHERE public_id=var_pubid and 
                             round=temp_maxvalue and job#=var_previd;
                      IF past_tenure>0 THEN 
                             var_tenure:=var_tenure + past_tenure;
                      ELSE var_tenure:=-3;
                      END IF;
                   END IF;
              EXCEPTION
                WHEN NO_DATA_FOUND THEN var_tenure:=-3;
               END;
               SELECT mnsb4dli INTO var_preten FROM datadba.emp_supplement
                      WHERE pubid=var_pubid AND employer=f;
                IF var_preten>-4 THEN 
                   IF var_preten>=0 THEN
                      IF var_tenure >=0 and var_preten>=0  THEN
                         var_tenure:=FLOOR(var_tenure + 4.3 * var_preten);
                      END IF;
                   ELSE var_preten:=-3;
                   END IF;
                END IF;
               END IF;
               IF var_tenure<0 THEN var_tenure:=-3; END IF;
               var_job_num_a:=max_value * 100 + f;
             SELECT jobstwhn, curwkemp, yleftjob, hrswk, occ, ind, cow, unionjob INTO  var_past, var_curwkemp, var_yleftjob, 
                          var_hrswk, var_occ, var_ind, var_cow, var_unionjob
             FROM datadba.emp_supplement
             WHERE pubid=var_pubid and employer=f;
             kount:=kount+1;
             /*IF max_value ^= 17 THEN 
             DBMS_OUTPUT.PUT_LINE('NON R17 rows being inserted!!!'); END IF;*/
             INSERT INTO datadba.jobs 
             VALUES (var_pubid, max_value, f, var_start, var_stajobcm, var_stajobcd, var_stajobcy, var_stop, var_stojobm, 
                  var_stojobd, var_stojoby, var_past, var_curwkemp, var_yleftjob, var_cps, var_hrswk, var_occ, var_ind, var_cow,
                  var_hrsdayu, var_payrate1, var_roptu, hrly_wage, var_unionjob, -4, var_anywjgap, var_per1_start, var_per1_stop, 
                  var_per1_reason, var_per1_all, var_per1_look, var_per2_start, var_per2_stop, var_per2_reason, var_per2_all, 
                  var_per2_look, var_per3_start, var_per3_stop, var_per3_reason, var_per3_all, var_per3_look, var_per4_start, 
                  var_per4_stop, var_per4_reason, var_per4_all, var_per4_look, var_previd, var_preten, var_tenure, var_job_num_a);
       END LOOP;
       COMMIT;
      END LOOP;
      CLOSE id_cursor;
      DBMS_OUTPUT.PUT_LINE('KOUNT='|| TO_CHAR(kount));
--EXCEPTION
--    WHEN NO_DATA_FOUND THEN
--       DBMS_OUTPUT.PUT_LINE('HALT!!! AT CASE-NO ROW ' || TO_CHAR(var_pubid));
--    WHEN OTHERS THEN
--        err_num:= sqlcode;
--        err_msg:= SUBSTR(SQLERRM,1,100);
--        DBMS_OUTPUT.PUT_LINE('FAILED CASE ' || TO_CHAR(var_pubid) || ' ' ||
--                                                TO_CHAR(max_value) || ' ' ||
--                                                TO_CHAR(var_job_num_a));
--        DBMS_OUTPUT.PUT_LINE('SQL ERROR# ' || TO_CHAR(err_num) || 
--                                       ' ' || err_msg);   
INSERT INTO datadba.error_tab VALUES
(var_pubid,NULL,NULL,var_start, var_stajobcm, var_stajobcd, var_stajobcy, var_stop, var_stojobm, 
var_stojobd, var_stojoby, var_past, var_curwkemp, var_yleftjob, var_cps, var_hrswk, var_occ, var_ind, var_cow,
var_hrsdayu, var_payrate1, var_roptu, hrly_wage, var_unionjob, -4, var_anywjgap, var_per1_start, var_per1_stop, 
var_per1_reason, var_per1_all, var_per1_look, var_per2_start, var_per2_stop, var_per2_reason, var_per2_all, 
var_per2_look, var_per3_start, var_per3_stop, var_per3_reason, var_per3_all, var_per3_look, var_per4_start, 
var_per4_stop, var_per4_reason, var_per4_all, var_per4_look, var_previd, var_preten, var_tenure, var_job_num_a);
END;
/

04_BETWEEN_JOBS.SQL

delete from datadba.betweenjobs where round=30;
set echo off;
set serveroutput on;
DECLARE
      max_value    INTEGER;
      var_pubid    INTEGER;
      temp_stabgam NUMBER(2);
      temp_stabgad NUMBER(2);
      temp_stabgay NUMBER(4);
      temp_stobgam NUMBER(2);
      temp_stobgad NUMBER(2);
      temp_stobgay NUMBER(4);
      temp_wkslkb1 NUMBER(2);
      temp_wkslkb2 NUMBER(3);
      temp_ynolkbg NUMBER(2);
      bstart_var   NUMBER(5);
      bstop_var    NUMBER(5);
      temp_wt      NUMBER(8);
      var_curintmo NUMBER(2);
      var_curintda NUMBER(2);
      var_curintyr NUMBER(4);
      var_lintmo   NUMBER(2);
      var_lintday  NUMBER(2);
      var_lintyr   NUMBER(4);
      CURSOR id_cursor IS
                       SELECT pubid,weight,curintmo,curintda,curintyr,
                              lintmo,lintday,lintyr
                       FROM datadba.newyear_data order by pubid;
      FUNCTION wk_number 
        (month  NUMBER, day NUMBER, year NUMBER)RETURN NUMBER IS
        wk_num  NUMBER(7,2);
        leap    NUMBER(7,3);
        days_month NUMBER(3);
        rday       NUMBER(3);
      BEGIN
        rday:=day;
        IF day<=0 THEN rday:=15; END IF;
        IF month =-1 OR year =-1 THEN
          RETURN -1;
        ELSIF month =-2 OR year =-2 THEN
          RETURN -2; 
        ELSIF month =-3 OR year =-3 THEN
          RETURN -3; 
        ELSIF month <=0 OR year <=0 THEN
          RETURN -4;
        END IF;  
        leap:=0;
        IF year <= 99 THEN 
           DBMS_OUTPUT.PUT_LINE('HALT!!! DATE^Y2K !!!');
        END IF;
        IF year>=1980 THEN
           leap:=CEIL((year-1980)/4);
        END IF;
        IF MOD(year,4)=0 AND month>2 THEN
           leap:=leap+1;
        END IF;
        IF month=1 THEN
          days_month:=0;
        END IF;
        IF month=2 THEN
            days_month:=31;
        END IF; 
        IF month=3 THEN
          days_month:=59;
        END IF;
        IF month=4 THEN
          days_month:=90;
        END IF;
        IF month=5 THEN
          days_month:=120;
        END IF;
        IF month=6 THEN
          days_month:=151;
        END IF;
        IF month=7 THEN
          days_month:=181;
        END IF;
        IF month=8 THEN
           days_month:=212;
        END IF;
        IF month=9 THEN
          days_month:=243;
        END IF;
        IF month=10 THEN
           days_month:=273;
        END IF;
        IF month=10 THEN
          days_month:=273;
        END IF;
        IF month=11 THEN
           days_month:=304;
        END IF;
        IF month=12 THEN
        days_month:=334;
         END IF;
        wk_num:=((year-1978) *365 + days_month + rday + leap)/7;
        RETURN(wk_num);
      END wk_number;
BEGIN
DBMS_OUTPUT.ENABLE(10000);
      SELECT MAX(round) INTO max_value
      FROM datadba.history;
      OPEN id_cursor;
      LOOP
          FETCH id_cursor INTO var_pubid,temp_wt,
                               var_curintmo,var_curintda,var_curintyr,
                               var_lintmo,var_lintday,var_lintyr;
          EXIT WHEN id_cursor%NOTFOUND;   
   /*     EXIT WHEN id_cursor%ROWCOUNT > 20;  */
          IF temp_wt > 0 THEN
           SELECT stabga1m,stabga1d,stabga1y,
                  stobga1m,stobga1d,stobga1y,
                  wkslkb11,wkslkb12,ynolkb1g INTO
                  temp_stabgam,temp_stabgad,temp_stabgay,
                  temp_stobgam,temp_stobgad,temp_stobgay,
                  temp_wkslkb1,temp_wkslkb2,temp_ynolkbg
           FROM datadba.gaps WHERE pubid=var_pubid;
           IF temp_stabgam >= -3 THEN
           IF CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay))=
              FLOOR(wk_number(temp_stabgam,temp_stabgad,temp_stabgay)) THEN
              bstart_var:=
                CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay))+1;
           ELSE
              bstart_var:=
                CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay));
           END IF;
           bstop_var:=
            CEIL(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); 
           IF temp_stobgam=var_curintmo AND
              temp_stobgad=var_curintda AND
              temp_stobgay=var_curintyr THEN
           bstop_var:=
             FLOOR(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); END IF; 
         
           IF bstart_var >= -3 THEN
            INSERT INTO datadba.betweenjobs
            VALUES (var_pubid,max_value,1,bstart_var,bstop_var,
                   temp_wkslkb1,temp_wkslkb2,temp_ynolkbg); 
           END IF; 
             ELSE GOTO nomore;
           END IF;
           SELECT stabga2m,stabga2d,stabga2y,
                  stobga2m,stobga2d,stobga2y,
                  wkslkb21,wkslkb22,ynolkb2g INTO
                  temp_stabgam,temp_stabgad,temp_stabgay,
                  temp_stobgam,temp_stobgad,temp_stobgay,
                  temp_wkslkb1,temp_wkslkb2,temp_ynolkbg
           FROM datadba.gaps WHERE pubid=var_pubid;
           IF temp_stabgam >= -3 THEN
           IF CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay))=
              FLOOR(wk_number(temp_stabgam,temp_stabgad,temp_stabgay)) THEN
              bstart_var:=
                CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay))+1;
           ELSE
              bstart_var:=
                CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay));
           END IF;
           bstop_var:=
            CEIL(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); 
           IF temp_stobgam=var_curintmo AND
              temp_stobgad=var_curintda AND
              temp_stobgay=var_curintyr THEN
           bstop_var:=
             FLOOR(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); END IF;
           IF bstart_var >= -3 THEN
            INSERT INTO datadba.betweenjobs
            VALUES (var_pubid,max_value,2,bstart_var,bstop_var,
                   temp_wkslkb1,temp_wkslkb2,temp_ynolkbg); 
           END IF; 
             ELSE GOTO nomore;
           END IF;
           SELECT stabga3m,stabga3d,stabga3y,
                  stobga3m,stobga3d,stobga3y,
                  wkslkb31,wkslkb32,ynolkb3g INTO
                  temp_stabgam,temp_stabgad,temp_stabgay,
                  temp_stobgam,temp_stobgad,temp_stobgay,
                  temp_wkslkb1,temp_wkslkb2,temp_ynolkbg
           FROM datadba.gaps WHERE pubid=var_pubid;
           IF temp_stabgam >= -3 THEN
           IF CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay))=
              FLOOR(wk_number(temp_stabgam,temp_stabgad,temp_stabgay)) THEN
              bstart_var:=
                CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay))+1;
           ELSE
              bstart_var:=
                CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay));
           END IF;
           bstop_var:=
            CEIL(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); 
           IF temp_stobgam=var_curintmo AND
              temp_stobgad=var_curintda AND
              temp_stobgay=var_curintyr THEN
           bstop_var:=
             FLOOR(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); END IF; 
 
           IF bstart_var >= -3 THEN
            INSERT INTO datadba.betweenjobs
            VALUES (var_pubid,max_value,3,bstart_var,bstop_var,
                   temp_wkslkb1,temp_wkslkb2,temp_ynolkbg); 
           END IF; 
             ELSE GOTO nomore;
           END IF;
           SELECT stabga4m,stabga4d,stabga4y,
                  stobga4m,stobga4d,stobga4y,
                  wkslkb41,wkslkb42,ynolkb4g INTO
                  temp_stabgam,temp_stabgad,temp_stabgay,
                  temp_stobgam,temp_stobgad,temp_stobgay,
                  temp_wkslkb1,temp_wkslkb2,temp_ynolkbg
           FROM datadba.gaps WHERE pubid=var_pubid;
           IF temp_stabgam >= -3 THEN
           IF CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay))=
              FLOOR(wk_number(temp_stabgam,temp_stabgad,temp_stabgay)) THEN
              bstart_var:=
                CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay))+1;
           ELSE
              bstart_var:=
                CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay));
           END IF;
           bstop_var:=
            CEIL(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); 
           IF temp_stobgam=var_curintmo AND
              temp_stobgad=var_curintda AND
              temp_stobgay=var_curintyr THEN
           bstop_var:=
             FLOOR(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); END IF; 
           IF bstart_var >= -3 THEN
            INSERT INTO datadba.betweenjobs
            VALUES (var_pubid,max_value,4,bstart_var,bstop_var,
                   temp_wkslkb1,temp_wkslkb2,temp_ynolkbg); 
           END IF; 
             ELSE GOTO nomore;
           END IF;
           SELECT stabga5m,stabga5d,stabga5y,
                  stobga5m,stobga5d,stobga5y,
                  wkslkb51,wkslkb52,ynolkb5g INTO
                  temp_stabgam,temp_stabgad,temp_stabgay,
                  temp_stobgam,temp_stobgad,temp_stobgay,
                  temp_wkslkb1,temp_wkslkb2,temp_ynolkbg
           FROM datadba.gaps WHERE pubid=var_pubid;
           IF temp_stabgam >= -3 THEN
           bstart_var:=
            CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay));
           IF temp_stabgam=var_lintmo AND
              temp_stabgad=var_lintday AND
              temp_stabgay=var_lintyr THEN 
           bstart_var:=bstart_var+1; END IF;
           bstop_var:=
            CEIL(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); 
           IF temp_stobgam=var_curintmo AND
              temp_stobgad=var_curintda AND
              temp_stobgay=var_curintyr THEN
           bstop_var:=
             FLOOR(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); END IF;
           IF bstart_var >= -3 THEN
            INSERT INTO datadba.betweenjobs
            VALUES (var_pubid,max_value,5,bstart_var,bstop_var,
                   temp_wkslkb1,temp_wkslkb2,temp_ynolkbg); 
           END IF; 
             ELSE GOTO nomore;
           END IF;
 
           SELECT stabga6m,stabga6d,stabga6y,
                  stobga6m,stobga6d,stobga6y,
                  wkslkb61,wkslkb62,ynolkb6g INTO
                  temp_stabgam,temp_stabgad,temp_stabgay,
                  temp_stobgam,temp_stobgad,temp_stobgay,
                  temp_wkslkb1,temp_wkslkb2,temp_ynolkbg
           FROM datadba.gaps WHERE pubid=var_pubid;
           IF temp_stabgam >= -3 THEN
           bstart_var:=
            CEIL(wk_number(temp_stabgam,temp_stabgad,temp_stabgay));
           IF temp_stabgam=var_lintmo AND
              temp_stabgad=var_lintday AND
              temp_stabgay=var_lintyr THEN 
           bstart_var:=bstart_var+1; END IF;
           bstop_var:=
            CEIL(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); 
           IF temp_stobgam=var_curintmo AND
              temp_stobgad=var_curintda AND
              temp_stobgay=var_curintyr THEN
           bstop_var:=
             FLOOR(wk_number(temp_stobgam,temp_stobgad,temp_stobgay)); END IF;
           IF bstart_var >= -3 THEN
            INSERT INTO datadba.betweenjobs
            VALUES (var_pubid,max_value,6,bstart_var,bstop_var,
                   temp_wkslkb1,temp_wkslkb2,temp_ynolkbg); 
           END IF; 
             ELSE GOTO nomore;
           END IF;    
           <<nomore>>
           COMMIT;
          END IF; 
      END LOOP;
      CLOSE id_cursor;
EXCEPTION
      WHEN OTHERS THEN
      ROLLBACK;       
END;    
/

05_MILITARY.SQL

set serveroutput on;
delete from datadba.military where round=30;
DECLARE
      max_value    INTEGER;
      max_week     INTEGER;
      var_pubid    INTEGER;
      temp_wt      NUMBER(8);
      t_current    NUMBER(4);
      t_last       NUMBER(4);
      t_status     NUMBER(4);
      start1       NUMBER(4);
      start2       NUMBER(4);
      stop1        NUMBER(4);
      stop2        NUMBER(4);
      wksl         NUMBER(4);
      t_miloutli     number (2);
      t_milinli      number (2);
      t_amilcrli     number (2);
      t_miloutm1     number (2);
      t_miloutd1     number (2);
      t_milouty1     number (4);
      t_milsinli     number (2);
      t_mlsinli2     number (2);
      t_mlsinli3     number (2);
      t_mlsinli4     number (2);
      t_mlsinli5     number (2);
      t_crmlsnli     number (2);
      t_amilsnli     number (2);
      t_milinm1      number (2);
      t_milind1      number (2);
      t_miliny1      number (4);
      t_srvactml     number (2);
      t_q4_12a       number (2);
      t_milinm2      number (2);
      t_milind2      number (2);
      t_miliny2      number (4);
      t_milinm3      number (2);
      t_milind3      number (2);
      t_miliny3      number (4);
      t_milinmc      number (2);
      t_milindc      number (2);
      t_milinyc      number (4);
      t_miloutm2     number (2);
      t_miloutd2     number (2);
      t_milouty2     number (4);
      t_miloutm3     number (2);
      t_miloutd3     number (2);
      t_milouty3     number (4);
      t_miloutmc     number (2);
      t_miloutdc     number (2);
      t_miloutyc     number (4);
      t_actmlnow     number (2);
      t_omilcode     number (2);
      CURSOR id_cursor IS
                       SELECT pubid FROM datadba.newyear_data order by pubid;
      FUNCTION wk_number
        (month NUMBER, day NUMBER, year NUMBER)RETURN NUMBER IS
        wk_num NUMBER(7,2);
        leap  NUMBER (7,3);
        days_month NUMBER (3);
      BEGIN
        IF month =-1 OR day =-1 OR year =-1 THEN
          RETURN -1;
        ELSIF month =-2 OR day =-2 OR year =-2 THEN
          RETURN -2;
        ELSIF month =-3 OR day =-3 OR year =-3 THEN
          RETURN -3;
        ELSIF month <=0 OR day <=0 OR year <=0 THEN
          RETURN -4;
        END IF;
        leap:=0;
        IF year <= 99 THEN
           DBMS_OUTPUT.PUT_LINE('HALT!!! DATE^Y2K !!!');
        END IF;
        IF year>=1980 THEN
           leap:=CEIL((year-1980)/4);
        END IF;
        IF MOD(year,4)=0 AND month>2 THEN
           leap:=leap+1;
        END IF;
        IF month=1 THEN
          days_month:=0;
        END IF;
        IF month=2 THEN
            days_month:=31;
        END IF;
        IF month=3 THEN
          days_month:=59;
        END IF;
        IF month=4 THEN
          days_month:=90;
        END IF;
        IF month=5 THEN
          days_month:=120;
        END IF;
        IF month=6 THEN
          days_month:=151;
        END IF;
        IF month=7 THEN
          days_month:=181;
        END IF;
        IF month=8 THEN
           days_month:=212;
        END IF;
        IF month=9 THEN
          days_month:=243;
        END IF;
        IF month=10 THEN
           days_month:=273;
        END IF;
        IF month=10 THEN
          days_month:=273;
        END IF;
        IF month=11 THEN
           days_month:=304;
        END IF;
        IF month=12 THEN
        days_month:=334;
         END IF;
          IF MONTH > 12 THEN
          DBMS_OUTPUT.PUT_LINE (TO_CHAR(VAR_PUBID) || '  ERROR, BAD MONTH VALUE: ' || TO_CHAR(MONTH));
          END IF;
        wk_num:=CEIL(((year-1978) *365 + days_month + day + leap)/7);
        RETURN(wk_num);
      END wk_number;
BEGIN
   SELECT MAX(round) INTO max_value FROM datadba.history;
   SELECT MAX(wk_num) INTO max_week FROM datadba.weeks;
   OPEN id_cursor;
   LOOP
       <<nextcase>>
       FETCH id_cursor INTO var_pubid;
       EXIT WHEN id_cursor%NOTFOUND;
   /*           EXIT WHEN id_cursor%ROWCOUNT> 500;  */
       SELECT weight,
              miloutli,
              milinli ,
              amilcrli,
              miloutm1, miloutd1, milouty1,
              milsinli,
              mlsinli2,
              mlsinli3,
              mlsinli4,
              mlsinli5,
              crmlsnli,
              amilsnli,
              milinm1, milind1, miliny1,
              srvactml,
              q4_12a,
              milinm2, milind2, miliny2,
              milinm3, milind3, miliny3,
              milinmc, milindc, milinyc,
              miloutm2, miloutd2, milouty2,
              miloutm3, miloutd3, milouty3,
              miloutmc, miloutdc, miloutyc,
              actmlnow,
              milstdli
               INTO
              temp_wt,
              t_miloutli,
              t_milinli ,
              t_amilcrli,
              t_miloutm1, t_miloutd1, t_milouty1,
              t_milsinli,
              t_mlsinli2,
              t_mlsinli3,
              t_mlsinli4,
              t_mlsinli5,
              t_crmlsnli,
              t_amilsnli,
              t_milinm1, t_milind1, t_miliny1,
              t_srvactml,
              t_q4_12a,
              t_milinm2, t_milind2, t_miliny2,
              t_milinm3, t_milind3, t_miliny3,
              t_milinmc, t_milindc, t_milinyc,
              t_miloutm2, t_miloutd2, t_milouty2,
              t_miloutm3, t_miloutd3, t_milouty3,
              t_miloutmc, t_miloutdc, t_miloutyc,
              t_actmlnow,
              t_omilcode
           FROM datadba.newyear_data WHERE pubid=var_pubid;
           IF temp_wt = 0 THEN GOTO nextcase; END IF;
           IF t_amilcrli ^=1 and t_amilsnli ^=1 and
              t_miloutm1 <=-4 THEN GOTO nextcase; END IF;
           SELECT lastint_wk#,currint_wk# INTO
               t_last,t_current
               FROM datadba.history WHERE public_id=var_pubid and round=max_value;
       start1 :=-4; start2 :=-4; stop1 :=-4;  stop2 :=-4; wksl :=-4;
-- Description: If r was serving in active military branch at dli then set start1 to dli
       IF (t_omilcode = 1 or t_omilcode = 2 or t_omilcode = 3 or t_omilcode = 4) THEN
           start1 :=t_last;
       END IF;
-- Description: If r was serving in active military branch at dli and is currently serving in the same branch, then set stop1 to intdate
       IF ((t_omilcode = 1 or t_omilcode = 2 or t_omilcode = 3 or t_omilcode = 4) and t_amilcrli = 1) THEN
           stop1 :=t_current;
-- Description: Else if r was serving in active military branch at dli and is not currently serving in that branch, and the exit date for active military service is present, then set stop1 to that exit date
-- Correction - changed t_amilcrli = 0 to t_amilcrli = -4
       ELSIF ((t_omilcode = 1 or t_omilcode = 2 or t_omilcode = 3 or t_omilcode = 4) and t_amilcrli = -4 and t_miloutm1 > -4) THEN
           stop1 := wk_number(t_miloutm1,t_miloutd1,t_milouty1);
       END IF;
--Description: If r enlisted in active armed forces since dli then …
       IF ((t_milsinli =1 or  t_milsinli =3) and (t_mlsinli2 =1 or (t_mlsinli2 =4 and (t_mlsinli3 =1 or t_mlsinli3 =4)))) or
          ((t_milsinli =2 or  t_milsinli =4) and (t_mlsinli4 =1 or (t_mlsinli4 =4 and (t_mlsinli5 =1 or t_mlsinli5 =4))))  THEN
--Description: …If R is currently serving in the active branch enlisted in since dli and there is no start1, then set start1 to the date entered active service branch since dli and stop1 to intdate
--Correction: this is where start1 should be set for pubid 4293.  It's not working, but I can't figure out why.  All the data appears to be there.
           IF  (t_crmlsnli =1 and start1=-4 and t_milinm1 > -4) THEN
               start1 := wk_number(t_milinm1,t_milind1,t_miliny1);
               stop1 := t_current;
--Description: …Else if R is currently serving in the active branch enlisted in since dli and start1 is already set, then set start2 to the date entered active service branch since dli and stop2 to intdate
           ELSIF (t_crmlsnli =1 and start1 > -4 and t_milinm1 > -4) THEN
               start2 := wk_number(t_milinm1,t_milind1,t_miliny1);
               stop2 := t_current;
--Description: …Else if R is not currently serving in the active branch enlisted in since dli, but r did serve on active duty and there is no start1, then set start1 to the date entered active duty branch since dli and stop1 to exit date from active duty branch enlisted in since dli
           ELSIF  (t_crmlsnli =0 and t_srvactml = 1 and start1=-4 and t_milinm2 > -4) THEN
               start1 := wk_number(t_milinm2,t_milind2,t_miliny2);
               stop1 := wk_number(t_miloutm2,t_miloutd2,t_milouty2);
--Description:…Else if R is not currently serving in the active branch enlisted in since dli, but r did serve on active duty and start1 is already set, then set start2 to the date entered active duty branch since dli and stop2 to exit date from active duty branch enlisted in since dli
           ELSIF  (t_crmlsnli =0 and t_srvactml = 1 and start1 > -4 and t_milinm2 > -4) THEN
               start2 := wk_number(t_milinm2,t_milind2,t_miliny2);
                stop2 := wk_number(t_miloutm2,t_miloutd2,t_milouty2);
           END IF;
        END IF;
       IF start1 >=0 and stop1 >=start1 THEN
           FOR f IN start1..stop1 LOOP
               UPDATE datadba.weeks SET status=7, hrs_worked=0  WHERE public_id=var_pubid and wk_num=f;
           END LOOP;
        END IF;
       IF start2 >=0 and stop2 >=start2 THEN
           FOR f IN start2..stop2 LOOP
               UPDATE datadba.weeks SET status=7, hrs_worked=0  WHERE public_id=var_pubid and wk_num=f;
           END LOOP;
        END IF;
       IF start1 >-4 or start2 >-4 or stop1  >-4 or stop2  >-4 THEN
           IF (start1 =-3 or start2 =-3 or stop1  =-3 or stop2  =-3) or start1 > stop1 or start2 > stop2  THEN
               wksl :=-3;
           ELSE
               IF start1 >=0 THEN wksl :=stop1-start1 + 1; END IF;
               IF start2 >=0 THEN wksl :=wksl +stop2 - start2 + 1; END IF;
               wksl :=FLOOR(wksl+.5);
           END IF;
       END IF;
      /* WKSC-Military wks in last cal yr is created in SUMMATION.SQL */
       IF start1 >=-3 or start2 >=-3 or stop1 >=-3 or stop2 >=-3 or wksl > 0 THEN
           INSERT INTO datadba.military VALUES (var_pubid,max_value,start1,start2,stop1,stop2,wksl,NULL);
       END IF;
       COMMIT WORK;
   END LOOP;
   CLOSE id_cursor;
END;
/
exit;

06_FILL.SQL

set serveroutput on ;
--********************************************************************************************************************
-- Change below constant number after '=' sign to current round
delete from datadba.dualjobs where floor(job/100)=30;
--********************************************************************************************************************
DECLARE
 CURSOR id_cursor IS SELECT pubid, weight FROM datadba.newyear_data ORDER BY pubid;
 var_pubid      INTEGER;
 var_weight     NUMBER(10);
 var_round      INTEGER;
 pr             INTEGER;
 filler         NUMBER(4);
 temp_prev_emp# INTEGER;
 w              NUMBER(6);
 var_startwk    NUMBER(4);
 var_stopwk     NUMBER(4);
 var_jobnum     NUMBER(4);
 var_hours      NUMBER(4);
 var_wks_not_wk NUMBER(4);
 debug_status   NUMBER(4);
 debug_hours    NUMBER(4);
 type number_array is table of number index by binary_integer;
 
 var_per_start  number_array;
 var_per_stop   number_array;
 var_per_reason number_array;
 var_per_all    number_array;
 var_per_look   number_array;
 var_gap_index  NUMBER(2);
 var_#weeks     NUMBER(4);
 temp_hours     NUMBER(4);
 max_dual       INTEGER;
 max_job#       INTEGER;
 max_per#       INTEGER;
 max_value      INTEGER;
 stat_code      INTEGER;
 temp_stat_code INTEGER;
 db_status      INTEGER;
 db_hours       INTEGER;
 dj             INTEGER;
 emp            INTEGER;
 var_bstart     NUMBER(4);
 var_bstop      NUMBER(4);
 var_ball       NUMBER(4);
 var_blook      NUMBER(4);
 var_breason    NUMBER(4);
 
BEGIN
 SELECT MAX(round) INTO max_value FROM datadba.jobs;
 OPEN id_cursor;
 <<respl>>
 LOOP
 <<nfetch>>
  FETCH id_cursor INTO var_pubid,var_weight;
    EXIT WHEN id_cursor%NOTFOUND;
  IF var_weight=0 THEN 
      GOTO nfetch; 
  END IF;
  FOR r IN REVERSE 1..(max_value-1) LOOP
    SELECT weight,round INTO var_weight,var_round FROM datadba.history
           WHERE public_id=var_pubid AND round=r;
    EXIT WHEN var_weight>0;
  END LOOP;
  BEGIN
    SELECT MAX(job#) INTO max_job# FROM datadba.jobs
       WHERE public_id=var_pubid AND round=max_value;
  EXCEPTION
    WHEN NO_DATA_FOUND THEN max_job#:=0;
  END;
  max_job#:=NVL(max_job#,0);
  /* Section for respondents with jobs */
  <<jobl>>
  FOR f IN 1..max_job# LOOP
   SELECT start_wk#,stop_wk#,job_num_a,hoursweek,wks_not_wk,
          per1_start, per2_start, per3_start,  per4_start,
          per1_stop,  per2_stop,  per3_stop,   per4_stop,
          per1_reason,per2_reason,per3_reason, per4_reason,
          per1_all,   per2_all,   per3_all,    per4_all,
          per1_look,  per2_look,  per3_look,   per4_look,
          prev_emp#
          INTO
          var_startwk,var_stopwk,var_jobnum,var_hours,var_wks_not_wk,
          var_per_start (1), var_per_start (2), var_per_start (3), var_per_start (4),
          var_per_stop (1), var_per_stop (2), var_per_stop (3), var_per_stop (4),
          var_per_reason (1), var_per_reason (2), var_per_reason (3), var_per_reason (4),
          var_per_all (1), var_per_all (2), var_per_all (3), var_per_all (4),
          var_per_look (1), var_per_look (2), var_per_look (3), var_per_look (4),
          temp_prev_emp#
          FROM datadba.jobs 
          WHERE public_id=var_pubid AND round=max_value AND job#=f; 
   
   IF var_startwk<0 OR var_stopwk< 0 THEN 
       GOTO nextjob; 
   END IF;
   IF var_hours < 0 THEN 
       var_hours:=-3;   
   END IF;
   IF var_hours >168 THEN 
       var_hours:=168; 
   END IF;
   <<weekl>>
   FOR w IN var_startwk..var_stopwk LOOP
      IF ((var_per_start (1) > 0) and (var_per_stop (1) > 0) and (w >= var_per_start (1)) and (w <= var_per_stop (1))) THEN
          var_gap_index := 1;
      ELSIF ((var_per_start (2) > 0) and (var_per_stop (2) > 0) and (w >= var_per_start (2)) and (w <= var_per_stop (2))) THEN
          var_gap_index := 2;
      ELSIF ((var_per_start (3) > 0) and (var_per_stop (3) > 0) and (w >= var_per_start (3)) and (w <= var_per_stop (3))) THEN
          var_gap_index := 3;
      ELSIF ((var_per_start (4) > 0) and (var_per_stop (4) > 0) and (w >= var_per_start (4)) and (w <= var_per_stop (4))) then
          var_gap_index := 4;
      ELSE
          var_gap_index := 0;
      END IF;
      
      temp_hours := var_hours;
      db_status := -999;
      db_hours := -999;
--DBMS_OUTPUT.put_line ('public_id: ' || to_char(var_pubid) || ' wk_num: ' || to_char(w));      
      SELECT status, hrs_worked INTO db_status, db_hours FROM datadba.weeks WHERE public_id=var_pubid AND wk_num=w;
      
      IF (db_status > 100) and (floor (db_status/100) <> max_value) THEN    /* if week already has a job from prev round - overlap */
          NULL;
      
      ELSIF (var_gap_index = 0) THEN      /* WORK WEEK */
          IF (db_status < 100) THEN      /* STRAIGHT JOB WEEK, UPDATE WEEKS TABLE */
              UPDATE datadba.weeks SET hrs_worked=temp_hours, status=var_jobnum
                     WHERE public_id=var_pubid AND wk_num=w;
                     
          ELSIF (db_status > 100) AND (db_status <> (var_round*100 + temp_prev_emp#)) THEN   /* JOB WEEK, EXISTING JOB IN WEEKS TABLE */
              BEGIN
                  SELECT MAX(dualjob_num) INTO max_dual FROM datadba.dualjobs WHERE public_id=var_pubid AND wk_num=w; 
              EXCEPTION
                  WHEN NO_DATA_FOUND THEN max_dual:=0;
              END;
              max_dual := NVL(max_dual,0);
              max_dual := max_dual+1; 
              dj := 0;
             IF (max_dual <= 4) then
                 dj := 1;
                 INSERT INTO datadba.dualjobs VALUES (var_pubid,w,max_dual,var_jobnum); 
              END IF;
              IF (temp_hours > 0 and db_hours >= 0) THEN
                  temp_hours := db_hours + temp_hours;
                  IF (temp_hours > 168) THEN 
                      temp_hours := 168;  
                  END IF;
                  UPDATE datadba.weeks SET hrs_worked = temp_hours WHERE public_id=var_pubid AND wk_num=w;
               ELSIF (temp_hours < 0) THEN
                  UPDATE datadba.weeks SET hrs_worked = -3 WHERE public_id=var_pubid AND wk_num=w;
               END IF;
          END IF;   /* JOB WEEK, EXISTING JOB IN WEEKS TABLE */
      ELSIF (var_gap_index > 0) and (db_status < 100) THEN      /* GAP WEEK  W/ NO GOOD JOB ALREADY IN DB */
          stat_code := 5;
          IF (var_per_reason (var_gap_index) = -4) THEN 
              stat_code := 2;
          ELSIF var_per_reason (var_gap_index) = 2 THEN 
              stat_code := 4;
          ELSIF var_per_reason (var_gap_index) = 3 OR var_per_reason (var_gap_index) = 4 THEN
              stat_code := 2;
              IF var_per_all (var_gap_index) = 1 THEN 
                 stat_code := 5; 
              ELSIF var_per_all (var_gap_index) = 3 THEN 
                 stat_code := 4; 
              ELSIF var_per_all (var_gap_index) = 2 AND var_per_look (var_gap_index) >= 0 THEN 
                  stat_code := 9; 
                  var_#weeks:=var_per_look (var_gap_index);
              END IF;
          END IF;
          filler := 0;
        
          IF (stat_code = 9) THEN
              IF (temp_hours > 0 AND db_hours > 0 AND (db_hours - temp_hours) > 0) THEN 
                  temp_hours := (db_hours - temp_hours);  
              ELSIF (temp_hours > 0) THEN 
                  temp_hours := 0;
              END IF;
              IF (filler < var_#weeks AND w > (var_stopwk-var_startwk-var_#weeks)/2 + var_startwk) THEN
                  stat_code := 4; 
                  filler := filler + 1;
              ELSIF (db_status <> 4) THEN 
                  stat_code:=5;
              END IF;
          END IF;
          IF (stat_code <> 3) THEN 
              temp_hours:=0; 
          END IF;
          UPDATE datadba.weeks SET status=stat_code,hrs_worked=temp_hours WHERE public_id=var_pubid and wk_num=w;
      ELSE                 /* OTHERWISE, SET STATUS TO '3' - IN JOB WEEK, BUT NOT A GOOD JOB AND NOT A GOOD GAP */
      
          UPDATE datadba.weeks SET status=3,hrs_worked=temp_hours WHERE public_id=var_pubid and wk_num=w and status < 100;
          
      END IF;
      COMMIT;
   
   END LOOP weekl;                
   <<nextjob>>
   NULL;
  END LOOP jobl;
 /* Begin between job gap fill   */
  SELECT max(period) INTO max_per# FROM datadba.betweenjobs WHERE public_id=var_pubid AND round=max_value;
  max_per#:=NVL(max_per#,0);
  stat_code := 0;
  
  <<periodl>>
  FOR p IN 1..max_per# LOOP
-- dbms_output.put_line ('pubid: ' || to_char(var_pubid) || '   round: ' || to_char(max_value) || '  period: ' || to_char(p));
   SELECT bstart,bstop,ball,blook,breason 
         INTO var_bstart,var_bstop,var_ball,var_blook,var_breason 
         FROM datadba.betweenjobs WHERE public_id=var_pubid AND round=max_value AND period=p;
   IF (var_bstart > 0 and var_bstop >= var_bstart) THEN 
       stat_code := 2;
       IF (var_ball = 1) THEN 
           stat_code := 5;
       ELSIF (var_ball = 3) THEN 
           stat_code := 4;
       ELSIF (var_ball = 2 and var_blook >= 0) THEN 
           stat_code := 9; 
           var_#weeks := var_blook; 
       END IF;
   END IF;
 
   filler:=0;
   temp_stat_code := stat_code;
--dbms_output.put_line ('pubid: ' || to_char(var_pubid) || '   var_bstart: ' || to_char(var_bstart) || '  var_bstop: ' || to_char(var_bstop));
   
   FOR w IN var_bstart..var_bstop LOOP   /* If gap starts/ends same week as job then leave job in the array */
       emp:=1;
       FOR j IN 1..max_job# LOOP
           SELECT start_wk#,stop_wk# INTO var_startwk,var_stopwk FROM datadba.jobs WHERE public_id=var_pubid AND job#=j AND round=max_value;
           IF (w = var_startwk OR w = var_stopwk) THEN 
               emp:=0; 
           END IF;
       END LOOP;
       IF (temp_stat_code = 9) THEN    
           IF (filler < var_#weeks) AND (w > (var_bstop-var_bstart-var_#weeks)/2 + var_bstart) THEN
              stat_code:=4; 
              filler:=filler+1;
           ELSE 
              stat_code:=5;
           END IF;
       END IF;      
       IF emp=1 THEN 
           UPDATE datadba.weeks SET status=stat_code, hrs_worked=0 WHERE public_id=var_pubid AND wk_num=w;
       END IF;
   END LOOP;
  END LOOP periodl;
 END LOOP respl;
END;
/
exit;

07_SUMMATION.SQL

set serveroutput on
delete from datadba.lastint where round=30;
delete from datadba.calendars where round=30;
DECLARE
      max_value       INTEGER;
      max_job#        INTEGER;
      max_week        INTEGER;
       max_wk_pcy      INTEGER;
      var_wt          NUMBER(10);
      var_pubid       INTEGER;
      var_start_wk#   INTEGER;
      var_stop_wk#    INTEGER;
      var_lastint_wk# INTEGER;
      var_current_wk# INTEGER;
      var_status      INTEGER;
      var_hrs_worked  INTEGER;
      var_job_num_a   INTEGER;
      var_prev_emp#   INTEGER;
      jf              INTEGER;
      var_workc         datadba.calendars.wks_workc%type;
      var_hourc         datadba.calendars.hrs_workc%type;
      var_wumpc         datadba.calendars.wks_umpc%type;
      var_wolfc         datadba.calendars.wks_olfc%type;
      var_cal_year_jobs datadba.calendars.cal_year_jobs%type;
      var_cal_year_job1 datadba.calendars.cal_year_job1%type;
      var_cal_year_job2 datadba.calendars.cal_year_job2%type;
      var_cal_year_job3 datadba.calendars.cal_year_job3%type;
      var_cal_year_job4 datadba.calendars.cal_year_job4%type;
      var_cal_year_job5 datadba.calendars.cal_year_job5%type;
      var_missc         datadba.calendars.wks_missc%type;
      var_nwmissc       datadba.calendars.wks_nwmissc%type;
      var_lastint_jobs  datadba.lastint.lastint_#jobs%type; 
      var_workl         datadba.lastint.wks_workl%type;
      var_hourl         datadba.lastint.hrs_workl%type;
      var_wumpl         datadba.lastint.wks_umpl%type;
      var_wolfl         datadba.lastint.wks_olfl%type;
      var_wbid          datadba.lastint.wks_bid%type;
      var_missl         datadba.lastint.wks_missl%type;
      var_nwmissl       datadba.lastint.wks_nwmissl%type;
      var_jobever       datadba.lastint.num_jobever%type;
      m_wksc            datadba.military.mil_wksc%type;
      err_msg           VARCHAR2(100);
      err_num           NUMBER;
      CURSOR id_cursor IS SELECT pubid FROM datadba.newyear_data order by pubid;
BEGIN
      SELECT MAX(round) INTO max_value FROM datadba.history;
      SELECT MAX(endwk) INTO max_week FROM datadba.master_weeks WHERE round#=max_value;
      /* This is used to establish round that WH is creating and
         'last calendar year' dates to be used.*/
      DBMS_OUTPUT.PUT_LINE('Work History for R ' || TO_CHAR(max_value) || 
                         ' Last Calendar Yr Wk#s ' || TO_CHAR(max_week-103)
                           || '-' || TO_CHAR(max_week));
      OPEN id_cursor;
      LOOP
          <<nfetch>>
          FETCH id_cursor INTO var_pubid;
          EXIT WHEN id_cursor%NOTFOUND;  
          SELECT weight,lastint_wk#,currint_wk# INTO 
          var_wt,var_lastint_wk#,var_current_wk#
          FROM datadba.history
          WHERE public_id=var_pubid AND round=max_value;
          IF var_wt = 0 THEN GOTO nfetch;  END IF;
      var_workc:=0;
      var_hourc:=0;
      var_wumpc:=0;
      var_wolfc:=0;
      var_cal_year_jobs:=0;
      var_cal_year_job1:=0;
      var_cal_year_job2:=0;
      var_cal_year_job3:=0;
      var_cal_year_job4:=0;
      var_cal_year_job5:=0;
      var_missc:=0;
      var_nwmissc:=0;
      var_lastint_jobs:=0;
      var_workl:=0;
      var_hourl:=0;
      var_wumpl:=0;
      var_wolfl:=0;
      var_wbid:=0;
      var_missl:=0;
      var_nwmissl:=0;
      var_jobever:=0;
      m_wksc:=0;
 /* Begin creation of variables SINCE LAST INT  */
          var_wbid:=var_current_wk#-var_lastint_wk# + 1;  /*WKS SINCE LINT */
          
          BEGIN                                          
            SELECT MAX(job#) INTO max_job# FROM datadba.jobs
              WHERE public_id=var_pubid AND round=max_value;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN max_job#:=0;
          END;
          max_job#:=NVL(max_job#,0);        
          var_lastint_jobs:=max_job#;       /*#JOBS SINCE LINT*/
          SELECT max(num_jobever) INTO var_jobever FROM datadba.lastint /*GET PREV MAX*/
            WHERE public_id=var_pubid;                       /*OF JOBS EVER*/
          IF var_jobever>=0 THEN 
            FOR k IN 1..var_lastint_jobs LOOP
               SELECT job_num_a,prev_emp# INTO 
                      var_job_num_a,var_prev_emp# FROM datadba.jobs
                      WHERE round=max_value AND public_id=var_pubid AND
                            job#=k;
               IF var_job_num_a > 100 AND var_prev_emp#=-3 THEN
                  var_jobever:=-3;
               ELSIF var_job_num_a > 100 AND
                      (var_prev_emp#=-4 OR var_prev_emp#=0 ) AND 
                       var_jobever>=0 THEN
                  var_jobever:=var_jobever+1;           /*#JOBS EVER HELD*/
               END IF;  
            END LOOP;
          END IF;
          
          FOR w IN var_lastint_wk#..var_current_wk# LOOP
            SELECT status,hrs_worked INTO 
            var_status,var_hrs_worked FROM datadba.weeks WHERE  
            public_id=var_pubid AND wk_num=w;
            IF var_status > 100 THEN 
              var_workl:=var_workl+1;             
              IF var_hrs_worked >= 0 and var_hourl >= 0 THEN
                 var_hourl:= var_hourl+var_hrs_worked;
              ELSE var_hourl:=-3;
              END IF;
            ELSIF var_status=4 THEN var_wumpl:=var_wumpl+1; 
            ELSIF var_status=2 THEN 
                  var_nwmissl:= var_nwmissl+1;
                  var_wumpl:=-3;
            ELSIF var_status=5 OR var_status=7 THEN var_wolfl:=var_wolfl+1;
            ELSIF var_status=3 THEN
                  var_workl:=var_workl+1;
                  var_missl:=var_missl+1;
                  var_wumpl:=-3;
                  var_wolfl:=-3;
                     IF var_hrs_worked >= 0 and var_hourl >= 0 THEN 
                       var_hourl:= var_hourl+var_hrs_worked;
                     ELSE var_hourl:=-3;
                     END IF;
            ELSE var_missl:=var_missl+1;
                     var_wumpl:=-3;
                     var_wolfl:=-3;
            END IF;
          END LOOP;
          /* Change to Percentages */
          IF var_missl>0 THEN 
          var_missl:=
             TRUNC((var_missl/(var_current_wk#-var_lastint_wk#+1))*100);
          END IF;
          IF var_missl>0 THEN 
          var_nwmissl:=
             TRUNC((var_nwmissl/(var_current_wk#-var_lastint_wk#+1))*100);
          END IF;
          INSERT INTO datadba.lastint VALUES (var_pubid,max_value,
              var_lastint_jobs,
              var_workl,
              var_hourl,
              var_wumpl,
              var_wolfl,
              var_wbid,
              var_missl,
              var_nwmissl,
              var_jobever);
  /* Begin creation of variables for CALENDAR YEAR  */
          max_wk_pcy := -4;
          IF (var_current_wk# <= max_week-52) then max_wk_pcy := var_current_wk#;
          ELSIF (var_current_wk# > max_week-52) then max_wk_pcy := max_week-52;
           END IF;
          FOR j IN REVERSE 1..max_job# LOOP
            SELECT start_wk#,stop_wk#,job_num_a INTO
                   var_start_wk#,var_stop_wk#,var_status FROM datadba.jobs WHERE
                   public_id=var_pubid AND round=max_value AND job#=j;
                jf:=0;
                FOR w IN var_start_wk#..var_stop_wk# LOOP
                   IF w >= max_week-103 AND w <=  max_wk_pcy THEN jf:=1; END IF;
                   EXIT WHEN jf=1;
                END LOOP;
               IF jf=1 THEN var_cal_year_jobs:=var_cal_year_jobs+1;
               IF    var_cal_year_jobs=1 THEN var_cal_year_job1:= var_status;
               ELSIF var_cal_year_jobs=2 THEN var_cal_year_job2:= var_status;
               ELSIF var_cal_year_jobs=3 THEN var_cal_year_job3:= var_status;
               ELSIF var_cal_year_jobs=4 THEN var_cal_year_job4:= var_status;
               ELSIF var_cal_year_jobs=5 THEN var_cal_year_job5:= var_status;
               END IF;
            END IF;
            END LOOP;
          FOR k IN max_week-103..max_wk_pcy LOOP
            SELECT status,hrs_worked INTO 
            var_status,var_hrs_worked FROM datadba.weeks WHERE  
            public_id=var_pubid AND wk_num=k;
            IF var_status > 100 THEN 
              var_workc:=var_workc+1;
              IF var_hourc >= 0 AND var_hrs_worked >= 0 THEN
                 var_hourc:=var_hourc+var_hrs_worked;
              ELSE var_hourc:=-3;
              END IF;
            ELSIF var_status=2 THEN var_nwmissc:=var_nwmissc+1;
                                    var_wumpc:=-3;
                                    var_wolfc:=-3;
            ELSIF var_status=4 AND var_wumpc^=-3 THEN var_wumpc:=var_wumpc+1;
            ELSIF var_status=5 AND var_wolfc^=-3 THEN var_wolfc:=var_wolfc+1;
         ELSIF var_status=7 THEN m_wksc:=m_wksc+1; /* Military Wks*/
           IF var_wolfc^=-3 THEN var_wolfc:=var_wolfc+1;END IF;  
            ELSIF var_status=3 THEN 
                  var_workc:=var_workc+1;
                  var_missc:=var_missc+1;
                  IF var_hourc >= 0 AND var_hrs_worked >= 0 THEN 
                     var_hourc:=var_hourc+var_hrs_worked;  
                  ELSE var_hourc:= -3; 
                  END IF;
                  var_wumpc:=-3;
                  var_wolfc:=-3;
            ELSE  var_missc:=var_missc+1;
                  var_wolfc:=-3;
                  var_wumpc:=-3; 
            END IF;
          END LOOP;
             IF m_wksc=0 THEN 
                 m_wksc:=-4; /* Sa: added*/
             END IF;
          IF var_missc>0 THEN 
              var_missc:=TRUNC((var_missc/52)*100);
          END IF;
          IF var_nwmissc>0 THEN 
              var_nwmissc:=TRUNC((var_nwmissc/52)*100);
          END IF;
          INSERT INTO datadba.calendars VALUES (var_pubid,max_value,
                  var_workc,
                  var_hourc,
                  var_wumpc,
                  var_wolfc,
                  var_cal_year_jobs,
                  var_cal_year_job1,
                  var_cal_year_job2,
                  var_cal_year_job3,
                  var_cal_year_job4,
                  var_cal_year_job5,
                  var_missc,
                  var_nwmissc);
          UPDATE datadba.military SET mil_wksc=m_wksc 
                 WHERE round=max_value AND public_id=var_pubid;
      END LOOP;
      CLOSE id_cursor;
END;    
/exit;

08_MAINVARS.SQL

set serveroutput on;
truncate table datadba.mainvars;
DECLARE
      var_pubid         NUMBER(5);
      var_norcid        NUMBER(7);
      var_round         NUMBER(2);
      var_weight        NUMBER(20);
      err_msg           VARCHAR2(100);
      err_num           NUMBER;
      v1                NUMBER(10);
      v2                NUMBER(10);
      v3                NUMBER(10);
      v4                NUMBER(10);
      v5                NUMBER(10);
      v6                NUMBER(10);
      v7                NUMBER(10);
      CURSOR id_cursor IS SELECT public_id,round,weight FROM datadba.history;
BEGIN
  OPEN id_cursor;
  LOOP
      <<nfetch>>
      FETCH id_cursor INTO var_pubid,var_round,var_weight;
      EXIT WHEN id_cursor%NOTFOUND;   
      IF var_weight = 0 THEN GOTO nfetch;  END IF;
      SELECT norcid INTO var_norcid FROM datadba.interview_status WHERE pubid=var_pubid;
  /* LAST INT VARIABLES */
  BEGIN
  SELECT wks_workl,hrs_workl,wks_umpl,wks_olfl,
         wks_bid,wks_missl,num_jobever INTO 
         v1,v2,v3,v4,v5,v6,v7 FROM datadba.lastint 
         WHERE public_id=var_pubid AND round=var_round;    
  EXCEPTION
         WHEN NO_DATA_FOUND THEN v1:=-4; v2:=-4; v3:=-4; v4:=-4; 
                                 v5:=-4; v6:=-4; v7:=-4;
  END;
  IF v1>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v1,'WKSWK-SLI');  END IF;
  IF v2>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v2,'HRSWK-SLI');  END IF;
  IF v3>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v3,'WKSUEMP-SLI');END IF;
  IF v4>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v4,'WKSOLF-SLI'); END IF;
  IF v5>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v5,'WKSSINCELI'); END IF;
  IF v6>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v6,'WKSUNACCT-SLI');END IF;
  IF v7>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v7,'JOBSNUM');    END IF;
  /* CALENDAR VARIABLES */
  BEGIN
  SELECT wks_workc,hrs_workc,wks_umpc,wks_olfc,wks_missc INTO
         v1,v2,v3,v4,v5 FROM datadba.calendars
         WHERE public_id=var_pubid AND round=var_round;    
  EXCEPTION
         WHEN NO_DATA_FOUND THEN v1:=-4; v2:=-4; v3:=-4; v4:=-4; v5:=-4;
  END;
  IF v1>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v1,'WKSWK-PCY');  END IF;
  IF v2>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v2,'HRSWK-PCY');  END IF;
  IF v3>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v3,'WKSUEMP-PCY');END IF;
  IF v4>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v4,'WKSOLF-PCY'); END IF;
  IF v5>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v5,'WKSUNACCT-PCY'); END IF;
  /* MILTARY VARIABLES */
  BEGIN
  SELECT mil_wksl,mil_wksc INTO v1,v2 FROM datadba.MILITARY
         WHERE public_id=var_pubid AND round=var_round;    
  EXCEPTION
         WHEN NO_DATA_FOUND THEN v1:=-4; v2:=-4;
  END;
  IF v1>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v1,'MILWK-SLI');  END IF;
  IF v2>=-3 THEN 
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v2,'MILWK-PCY');  END IF;
  /* JOB VARIABLES */
  BEGIN
  SELECT hourly_wage,tenure,pay_rate INTO v1,v2,v3 FROM datadba.JOBS 
         WHERE public_id=var_pubid AND round=var_round AND job#=1;
  EXCEPTION
         WHEN NO_DATA_FOUND THEN v1:=-4; v2:=-4; v3:=-4;
  END;
  IF v1>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v1,'HRP1');  END IF;
  IF v2>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v2,'TENURE1');  END IF;
  IF v3>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v3,'PAYRATE-ALL-EMP1'); END IF;
  BEGIN
  SELECT hourly_wage,tenure,pay_rate INTO v1,v2,v3 FROM datadba.JOBS 
         WHERE public_id=var_pubid AND round=var_round AND job#=2;
  EXCEPTION
         WHEN NO_DATA_FOUND THEN v1:=-4; v2:=-4; v3:=-4;
  END;
  IF v1>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v1,'HRP2');  END IF;
  IF v2>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v2,'TENURE2');  END IF;
  IF v3>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v3,'PAYRATE-ALL-EMP2'); END IF;
  BEGIN
  SELECT hourly_wage,tenure,pay_rate INTO v1,v2,v3 FROM datadba.JOBS 
         WHERE public_id=var_pubid AND round=var_round AND job#=3;
  EXCEPTION
         WHEN NO_DATA_FOUND THEN v1:=-4; v2:=-4; v3:=-4;
  END;
  IF v1>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v1,'HRP3');  END IF;
  IF v2>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v2,'TENURE3');  END IF;
  IF v3>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v3,'PAYRATE-ALL-EMP3'); END IF;
  BEGIN
  SELECT hourly_wage,tenure,pay_rate INTO v1,v2,v3 FROM datadba.JOBS 
         WHERE public_id=var_pubid AND round=var_round AND job#=4;
  EXCEPTION
         WHEN NO_DATA_FOUND THEN v1:=-4; v2:=-4; v3:=-4;
  END;
  IF v1>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v1,'HRP4');  END IF;
  IF v2>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v2,'TENURE4');  END IF;
  IF v3>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v3,'PAYRATE-ALL-EMP4'); END IF;
  BEGIN
  SELECT hourly_wage,tenure,pay_rate INTO v1,v2,v3 FROM datadba.JOBS 
         WHERE public_id=var_pubid AND round=var_round AND job#=5;
  EXCEPTION
         WHEN NO_DATA_FOUND THEN v1:=-4; v2:=-4; v3:=-4;
  END;
  IF v1>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v1,'HRP5');  END IF;
  IF v2>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v2,'TENURE5');  END IF;
  IF v3>=-3 THEN
  INSERT INTO datadba.mainvars VALUES (var_pubid,var_norcid,var_round,v3,'PAYRATE-ALL-EMP5'); END IF;
  COMMIT;
  END LOOP;
  CLOSE id_cursor;
EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('HALT ' || TO_CHAR(var_pubid) || ' ' ||
                                    TO_CHAR(var_round));
    err_num:= sqlcode;
    err_msg:= SUBSTR(SQLERRM,1,100);
    DBMS_OUTPUT.PUT_LINE('SQL ERROR# ' || TO_CHAR(err_num) || 
                                      ' ' || err_msg);
END;    
/
exit;

Listed below are programs that generate input variables for the Work History arrays and a number of other related variables. These inputs are loaded into data table structures and then used in a series of SQL programs to create the Work History arrays and other variables. Some of the variables created as inputs for Work History are also released as public variables independently. The contents of these data tables and the SQL programs can be accessed in the Work History Variable Creation Programs above.

PREVID_RESET_2022.SAS

options nocenter validvarname=any;

*There is a max of 14 jobs in R30;

Variable Names in program    Variable Names in data release
CURDAY                       CURDATE~D
CURMO                        CURDATE~M
CURYR                        CURDATE~Y
Lintdat                      SYMBOL_LINTDATE~D
Lintmo                       SYMBOL_LINTDATE~M
Lintyr                       SYMBOL_LINTDATE~Y
empname_wrong                DLI-2A_1~000002
dliemp_added                 DLI-2A_1~000005
empname_change               DLI-FIXROSTER
tempid## (1-14)              TEMPLOYER_ID.## (1-14)
tempast## (1-14)             TEMPLOYER_ASSIGNMT.## (1-14)
tempname## (1-14)            TEMPLOYER_NAME.## (1-14)
tempuid## (1-14)             TEMPLOYERU_ID.## (1-14)
tempuname## (1-14)           TEMPLOYERU_NAME.## (1-14)
empid## (1-14)               EMPLOYER_ID.## (1-14)
empname## (1-14)             EMPLOYER_NAME.## (1-14)
empast## (1-14)              EMPLOYER_ASSIGNMT.## (1-14)
dliname## (1-4)              DLI_UPD1_NAME.## (1-4)

array all        lintmo lintdat lintyr tempid1-tempid14 tempuid1-tempuid14 empid1-empid14;

do over all;
    if all=. then all=-4;
end;

array    tempnm    (i)    $    tempname1-tempname14;
array    tempast    (i)        tempast1-tempast14;
array    tempunm    (i)    $    tempuname1-tempuname14;
array    empid    (i)        empid1-empid14;
array    empname    (i)    $    empname1-empname14;

ct_temp=0;
ct_tempast=0;
ct_tempu=0;
ct_emp=0;
do i=1 to 14;
    if ct_tempast=1 then ct_tempast=ct_tempast+1;
    if tempnm~=' ' then ct_temp=ct_temp+1;
    if tempunm~=' ' then ct_tempu=ct_tempu+1;
    if empname~=' ' then ct_emp=ct_emp+1;
end;

if (ct_emp>ct_temp|ct_emp>ct_tempu) & ct_tempast=0 then handedit=1;
if (ct_emp<ct_temp|ct_emp<ct_tempu) & ct_tempast=0 then problem_case=1;

array previd    (14)        previd_reset1-previd_reset14;
array empid        (14)        empid1-empid14;
array tempuid    (14)        tempuid1-tempuid14;

do i=1 to 14;
    previd(i) = -4;
    if (empid(i)>-4 & tempuid(i)>-4) then previd(i)=tempuid(i);
    if (empid(i)>-4 & (tempuid(i)=0 | tempuid(i)=-4)) then previd(i)=-4;
end;

ES_EXTRACT_2022_ORACLE.SAS

Variable Names in program    Variable Names in survey instrument
 INT_D                        CURDATE~D
 INT_M                        CURDATE~M
 INT_Y                        CURDATE~Y
 E##COWCD                     EMPLOYER_COWCODE.## (1-14)
 JOBTYP##                     EMPLOYER_FJOBTYPE.## (1-14)
 PREVID##                     EMPLOYER_ID.## (1-14)
 STAJOBD##                    EMPLOYER_STARTDATE.##~D (1-14)
 STAJOBM##                    EMPLOYER_STARTDATE.##~M (1-14)
 STAJOBY##                    EMPLOYER_STARTDATE.##~Y (1-14)
 STOJOBD##                    EMPLOYER_STOPDATE.##~D (1-14)
 STOJOBM##                    EMPLOYER_STOPDATE.##~M (1-14)
 STOJOBY##                    EMPLOYER_STOPDATE.##~Y (1-14)
 NTNGAP##                     NTES-28B.## (1-14)
 NTSRGD##                     NTES-28D.##~D (1-14)
 NTSRGM##                     NTES-28D.##~M (1-14)
 NTSRGY##                     NTES-28D.##~Y (1-14)
 NTERGD##                     NTES-28E.##~D (1-14)
 NTERGM##                     NTES-28E.##~M (1-14)
 NTERGY##                     NTES-28E.##~Y (1-14)
 NTSLGD##                     NTES-28F.##~D (1-14)
 NTSLGM##                     NTES-28F.##~M (1-14)
 NTSLGY##                     NTES-28F.##~Y (1-14)
 NTELGD##                     NTES-28G.##~D (1-14)
 NTELGM##                     NTES-28G.##~M (1-14)
 NTELGY##                     NTES-28G.##~Y (1-14)
 NTMROP##                     NTES-50A1.## (1-14)
 Miloutli                     Q4-1A
 Milinli                      Q4-1B
 Crmlsnli                     Q4-10
 Amilsnli                     Q4-11
 q4_11a_m                     Q4-11A~M
 q4_11a_y                     Q4-11A~Y
 milind1                      Q4-11B~D
 milinm1                      Q4-11B~M
 miliny1                      Q4-11B~Y
 srvactml                     Q4-12
 milind2                      Q4-12B~D
 milinm2                      Q4-12B~M
 miliny2                      Q4-12B~Y
 milind3                      Q4-12C~D
 milinm3                      Q4-12C~M
 miliny3                      Q4-12C~Y
 miloutd2                     Q4-13~D
 miloutm2                     Q4-13~M
 milouty2                     Q4-13~Y
 miloutd3                     Q4-13A~D
 miloutm3                     Q4-13A~M
 milouty3                     Q4-13A~Y
 q4_28                        Q4-28
 q4_3                         Q4-3
 actmlnow                     Q4-30
 amilcrli                     Q4-5A
 q4_6_m                       Q4-6~M
 q4_6_y                       Q4-6~Y
 miloutd1                     Q4-6A~D
 miloutm1                     Q4-6A~M
 milouty1                     Q4-6A~Y
 milsinli                     Q4-9
 q4_9a_a                      Q4-9A-A
 mlsinli2                     Q4-9A
 mlsinli3                     Q4-9A1
 mlsinli4                     Q4-9B
 mlsinli5                     Q4-9B1
 q4_c                         Q4-C
 stabgpd##                    Q7-10.##~D (1-6)
 stabgpm##                    Q7-10.##~M (1-6)
 stabgpy##                    Q7-10.##~Y (1-6)
 stobgpd##                    Q7-11.##~D (1-6)
 stobgpm##                    Q7-11.##~M (1-6)
 stobgpy##                    Q7-11.##~Y (1-6)
 wklkbg1##                    Q7-12.## (1-6)
 q7_15_##                     Q7-15.## (1-6)
 wklkbg##2                    Q7-16.## (1-6)
 q7_17_##                     Q7-17.## (1-6)
 ynolkb##g                    Q7-19.## (1-6)
 q7_9                         Q7-9
 q7_a                         Q7-A
 CRWKEMP#                     EMPLOYER_CURFLAG.01 (1-14)
 YLFTJOB#                     QES-23A.14
 ANYWJGP#                     QES-28.14
 STAWG####D                   QES-30.##.##~D (job 1-14, within job gap 1-4)
 STAWG####M                   QES-30.##.##~M (job 1-14, within job gap 1-4)
 STAWG####Y                   QES-30.##.##~Y (job 1-14, within job gap 1-4)
 STOWG####D                   QES-31.##.##~D (job 1-14, within job gap 1-4)
 STOWG####M                   QES-31.##.##~M (job 1-14, within job gap 1-4)
 STOWG####Y                   QES-31.##.##~Y (job 1-14, within job gap 1-4)
 YNWKG####1                   QES-33.##.## (job 1-14, within job gap 1-4)
 WKLKG####1                   QES-36.##.## (job 1-14, within job gap 1-4)
 WKLKG####2                   QES-40.##.## (job 1-14, within job gap 1-4)
 QES4A_##                     QES-4A.## (1-14)
 JBSTWHN##                    QES-4B.## (1-14)
 HRSDAYU##                    QES-51.## (1-14)
 HRSWKU##                     QES-52A.## (1-14)
 HRWKUHM##                    QES-52D.## (1-14)
 e_53b_##                     QES-53B.## (1-14)
 e_54b_##                     QES-54B.## (1-14)
 OCCSMLI##                    QES-55DC.## (1-14)
 COWNEW##                     QES-56B.## (1-14)
 MNSB4LI##                    QES-6.## (1-14)
 ROPTU##                      QES-71G.## (1-14)
 HRROP##1                     QES-71I.## (1-14)
 HRROP##2                     QES-71J.## (1-14)
 HRROP##3                     QES-71P.## (1-14)
 HRROP##4                     QES-71R.## (1-14)
 HRROP##5                     QES-73J.## (1-14)
 WKROP##1                     QES-74D.## (1-14)
 WKROP##2                     QES-74E.## (1-14)
 WKROP##3                     QES-74K.## (1-14)
 WKROP##4                     QES-74M.## (1-14)
 WKROP##5                     QES-74Q.## (1-14)
 WKROP##6                     QES-74R.## (1-14)
 MOROP##1                     QES-74U.## (1-14)
 MOROP##2                     QES-74V.## (1-14)
 MOROP##3                     QES-75B.## (1-14)
 MOROP##4                     QES-75D.## (1-14)
 MOROP##6                     QES-75H.## (1-14)
 YRROP##1                     QES-75J.## (1-14)
 YRROP##2                     QES-75K.## (1-14)
 YRROP##3                     QES-75Q.## (1-14)
 YRROP##4                     QES-75S.## (1-14)
 YRROP##5                     QES-75V.## (1-14)
 YRROP##6                     QES-75W.## (1-14)
 BWROP##1                     QES-75Y.## (1-14)
 BWROP##2                     QES-75Z.## (1-14)
 BWROP##3                     QES-76F.## (1-14)
 BWROP##4                     QES-76H.## (1-14)
 ES_8_##                      QES-8.## (1-14)
 UNIONJB##                    QES-88B.## (1-14)
 TEACH##                      QES-TEACH1.## (1-14)
 TCSHRW##                     QES-TEACH10.## (1-14)
 TCSNUM##                     QES-TEACH11.## (1-14)
 THRSWK##                     QES-TEACH13.## (1-14)
 TAPAY####                    QES-TEACH17.##.## (job 1-14, teaching assignment 1-3)
 TADWK####                    QES-TEACH18.##.## (job 1-14, teaching assignment 1-3)
 TADHR####                    QES-TEACH19.##.## (job 1-14, teaching assignment 1-3)
 TREGSC##                     QES-TEACH2.## (1-14)
 TADAPT##                     QES-TEACH5.## (1-14)
 TYROP##                      QES-TEACH6.## (1-14)
 TCSPAY##                     QES-TEACH7.## (1-14)
 TCSROP##                     QES-TEACH8.## (1-14)
 TCSWKS##                     QES-TEACH9.## (1-14)
 YLFTSEJ##                    SES-BUSOWN-23A.## (1-14)
 HRWKSEU##                    SES-52A.## (1-14)
 HRWKSEH##                    SES-52D.## (1-14)
 SEYROP##                     SES-71A.## (1-14)
 Milact                       SYMBOL_ACTIVEFLAG
 LINT_D                       SYMBOL_LINTDATE~D
 LINT_M                       SYMBOL_LINTDATE~M
 LINT_Y                       SYMBOL_LINTDATE~Y
 Omilcode                     SYMBOL_OLDMILCODE
 INDNWDS##                    QES-55E.## (1-14)
 OCCNWDS##                    QES-55H.## (1-14)
 TPEROP##                     QES-TEACH12.## (1-14)
 
do over newvarschar;
  if missing(oldvarschar) then do;
     call missing(newvarschar);
     end;
  else newvarschar=oldvarschar;
end;

************************;
************************;
************************;
*  employers #1 - #14   ;
************************;
************************;
************************;
array stajobm (i) stajobm1-stajobm14;
array stajobd (i) stajobd1-stajobd14;
array stajoby (i) stajoby1-stajoby14;
array stojobm (i) stojobm1-stojobm14;
array stojobd (i) stojobd1-stojobd14;
array stojoby (i) stojoby1-stojoby14;
array _stamdy (i) _stamdy1-_stamdy14;
array _stomdy (i) _stomdy1-_stomdy14;

do i = 1 to 14;
    if stajoby=stojoby & stajobm=stojobm & stojobd>15 & stajobd in (-1,-2,-3,0) then stajobd=1;
    if stajoby=stojoby & stajobm=stojobm & stajobd<28 & stojobd in (-1,-2,-3,0) then stojobd=28;
   if stajobm>0 & stajobd>0 & stajoby>0 then _stamdy=mdy(stajobm,stajobd,stajoby);
   if stajobm>0 & stajobd in (-1,-2,-3,0) & stajoby>0 then _stamdy=mdy(stajobm,15,stajoby);
   if stojobm>0 & stojobd>0 & stojoby>0 then _stomdy=mdy(stojobm,stojobd,stojoby);
   if stojobm>0 & stojobd in (-1,-2,-3,0) & stojoby>0 then _stomdy=mdy(stojobm,15,stojoby);
end;

lintmdy=mdy(lint_m,lint_d,lint_y);
array back_reported     (i)     back_reported1-back_reported14;

do i = 1 to 14;
   if stajobm>0 & stajobd>0 & stajoby>0 then _stamdy=mdy(stajobm,stajobd,stajoby);
   if stajobm>0 & stajobd in (-1,-2,-3,0) & stajoby>0 then _stamdy=mdy(stajobm,15,stajoby);
    if _stamdy>0 & _stamdy<lintmdy then back_reported=1;
end;

************************;
************************;
*  compute old jbstwhn  ;
************************;
************************;

array whnstrt (i) whnstrt1-whnstrt14;
array jbstwhn (i) jbstwhn1-jbstwhn14;

do i = 1 to 14;
  whnstrt=-4;
end;

do i = 1 to 14;
  if (stajobm eq -4) then whnstrt=-4;
  else if (stajobm eq lint_m and stajobd eq lint_d and
         stajoby eq lint_y) then whnstrt=2;
  else if (stajoby lt lint_y) then whnstrt =1;
  else if (stajoby gt lint_y) then whnstrt=3;
  else if (stajoby eq lint_y and stajobm lt lint_m)
         then whnstrt=1;
  else if (stajoby eq lint_y and stajobm eq lint_m and
         stajobd lt lint_d) then whnstrt=1;
  else if (stajoby eq lint_y and stajobm gt lint_m)
         then whnstrt=3;
  else if (stajoby eq lint_y and stajobm eq lint_m and
         stajobd gt lint_d) then whnstrt=3;
  else whnstrt=-3;
end;

do i = 1 to 14;
  jbstwhn=whnstrt;
end;

************************;
************************;
*compute reasons for gap;
************************;
************************;
array ynwkg_1c (i) ynwkg11c ynwkg21c ynwkg31c ynwkg41c ynwkg51c ynwkg61c ynwkg71c ynwkg81c ynwkg91c ynwkg101c ynwkg111c ynwkg121c ynwkg131c ynwkg141c;
array ynwkg_2c (i) ynwkg12c ynwkg22c ynwkg32c ynwkg42c ynwkg52c ynwkg62c ynwkg72c ynwkg82c ynwkg92c ynwkg102c ynwkg112c ynwkg122c ynwkg132c ynwkg142c;
array ynwkg_3c (i) ynwkg13c ynwkg23c ynwkg33c ynwkg43c ynwkg53c ynwkg63c ynwkg73c ynwkg83c ynwkg93c ynwkg103c ynwkg113c ynwkg123c ynwkg133c ynwkg143c;
array ynwkg_4c (i) ynwkg14c ynwkg24c ynwkg34c ynwkg44c ynwkg54c ynwkg64c ynwkg74c ynwkg84c ynwkg94c ynwkg104c ynwkg114c ynwkg124c ynwkg134c ynwkg144c;
array ynwkg_11 (i) ynwkg111 ynwkg211 ynwkg311 ynwkg411 ynwkg511 ynwkg611 ynwkg711 ynwkg811 ynwkg911 ynwkg1011 ynwkg1111 ynwkg1211 ynwkg1311 ynwkg1411;
array ynwkg_21 (i) ynwkg121 ynwkg221 ynwkg321 ynwkg421 ynwkg521 ynwkg621 ynwkg721 ynwkg821 ynwkg921 ynwkg1021 ynwkg1121 ynwkg1221 ynwkg1321 ynwkg1421;
array ynwkg_31 (i) ynwkg131 ynwkg231 ynwkg331 ynwkg431 ynwkg531 ynwkg631 ynwkg731 ynwkg831 ynwkg931 ynwkg1031 ynwkg1131 ynwkg1231 ynwkg1331 ynwkg1431;
array ynwkg_41 (i) ynwkg141 ynwkg241 ynwkg341 ynwkg441 ynwkg541 ynwkg641 ynwkg741 ynwkg841 ynwkg941 ynwkg1041 ynwkg1141 ynwkg1241 ynwkg1341 ynwkg1441;

******************************;
*  compute reason for gap #1  ;
******************************;
do i = 1 to 14;
  ynwkg_1c=-4;
end;

do i = 1 to 14;
  if (ynwkg_11 >= -4) then ynwkg_1c=ynwkg_11;
  else ynwkg_1c=-6;
end;

******************************;
*  compute reason for gap #2  ;
******************************;
do i = 1 to 14;
  ynwkg_2c=-4;
end;

do i = 1 to 14;
  if (ynwkg_21 >= -4) then ynwkg_2c=ynwkg_21;
  else ynwkg_2c=-6;
end;

******************************;
*  compute reason for gap #3  ;
******************************;
do i = 1 to 14;
  ynwkg_3c=-4;
end;

do i = 1 to 14;
  if (ynwkg_31 >= -4) then ynwkg_3c=ynwkg_31;
  else ynwkg_3c=-6;
end;

******************************;
*  compute reason for gap #4  ;
******************************;
do i = 1 to 14;
 ynwkg_4c=-4;
end;

do i = 1 to 14;
  if (ynwkg_41 >= -4) then ynwkg_4c=ynwkg_41;
  else ynwkg_4c=-6;
end;

************************;
************************;
*  compute hours worked ;
************************;
************************;
array hrwkuhm (i) hrwkuhm1-hrwkuhm14;
array hrswku  (i) hrswku1-hrswku14;
array crwkemp (i) crwkemp1-crwkemp14;
array jobtyp  (i) jobtyp1-jobtyp14;
array hrswk   (i) hrswk1-hrswk14;
************************;
* hours worked per week ;
************************;
do i = 1 to 14;
  hrswk=-4;
end;

do i = 1 to 14;
  if jobtyp ~=3 then do;
    if (hrwkuhm ~= -4) then hrswk=hrwkuhm;
    else if (hrswku ~= -4) then hrswk=hrswku;
    else if (crwkemp = -4) then hrswk=-4;
    else hrswk=-6;
  end;
end;

*************************************;
*hours worked per week--self-employed;
*************************************;
array hrwkseh (i) hrwkseh1-hrwkseh14;

do i = 1 to 14;
  if jobtyp=3 then do;
    if (hrwkseh ~= -4) then hrswk=hrwkseh;
    else if (crwkemp = -4) then hrswk=-4;
    else hrswk=-6;
  end;
end;

*************************************;
*  hours worked per week--teachers   ;
*************************************;
array tregsc  (i) tregsc1-tregsc14;
array tcspay  (i) tcspay1-tcspay14;
array tadapt  (i) tadapt1-tadapt14;
array thrswk  (i) thrswk1-thrswk14;
array tadwk_1 (i) tadwk11-tadwk141;
array tadwk_2 (i) tadwk12-tadwk142;
array tadwk_3 (i) tadwk13-tadwk143;
array tadhr_1 (i) tadhr11-tadhr141;
array tadhr_2 (i) tadhr12-tadhr142;
array tadhr_3 (i) tadhr13-tadhr143;

do i = 1 to 14;
  if tregsc=1 then do;
    if tcspay in (0,-4) & tadapt=0 & thrswk ~= -4 then hrswk=thrswk;
    if tadapt=1 then do;
       if tadwk_1 >= 0 & tadwk_2 >= 0 & tadwk_3 >= 0 then do;
       hrswk=(((tadwk_1*tadhr_1)+(tadwk_2*tadhr_2)+(tadwk_3*tadhr_3))/52) + thrswk;
       end;
       if tadwk_1 >= 0 & tadwk_2 >= 0 & tadwk_3 < 0 then do;
       hrswk=(((tadwk_1*tadhr_1)+(tadwk_2*tadhr_2))/52) + thrswk;
       end;
       if tadwk_1 >= 0 & tadwk_2 < 0 & tadwk_3 < 0 then do;
       hrswk=((tadwk_1*tadhr_1)/52) + thrswk;
       end;
    end;
    if tcspay=1 & hrswk <= 0 then hrswk=-6;
  end;
end;

***************************************************************************;
*calculation for teacher hours creates decimal values--round to nearest one;
***************************************************************************;
do i = 1 to 14;
  if hrswk>0 then do;
    hrswk=round(hrswk,1);
  end;
end;

*****************************************;
*****************************************;
*why left job?  recodes for self-employed;
*****************************************;
*****************************************;
array ylftsej (i) ylftsej1-ylftsej14;
array ylftjob (i) ylftjob1-ylftjob14;

do i = 1 to 14;
  if jobtyp=3 then do;
    if ylftsej=1 then ylftjob=22;
    if ylftsej=2 then ylftjob=23;
    if ylftsej=3 then ylftjob=24;
    if ylftsej=4 then ylftjob=25;
    if ylftsej in (-1,-2) then ylftjob=ylftsej;
  end;
end;

*****************;
*****************;
* class of worker;
*****************;
*****************;
array cow     (i) cow1-cow14;
array occsmli (i) occsmli1-occsmli14;
array indnwds (i) indnwds1-indnwds14;
array occnwds (i) occnwds1-occnwds14;
array cownew  (i) cownew1-cownew14;
array empnum  (i) empnum1-empnum14;
array ecowcd  (i) e1cowcd e2cowcd e3cowcd e4cowcd e5cowcd e6cowcd e7cowcd e8cowcd e9cowcd e10cowcd e11cowcd e12cowcd e13cowcd e14cowcd;
array e_53b   (i) e_53b_1-e_53b_14;
array e_54b   (i) e_54b_1-e_54b_14;

do i = 1 to 14;
    empnum=-4;
   cow=-4;
end;

do i = 1 to 14;
   if (crwkemp ~= -4 & crwkemp ~= -5) then empnum=i;
   else if (crwkemp = -5) then empnum=-5;
end;

do i = 1 to 14;
   if (empnum > -4 & cownew ~= -4) then cow=cownew; 
   else if (empnum > -4 & ecowcd ~= -4) then cow=ecowcd;
   else if (empnum > -4 & e_53b~=0 & e_54b~=0) then cow=-3;
    if (crwkemp > -4 & (cow = 0|cow = -3) & jobtyp = 3) then cow=4;
end;

*************;
*************;
*  PAYRATES  ;
*************;
*************;
******************;
******************;
* basic payrates  ;
******************;
******************;
array payrate (i)     payrate1-payrate14;
array roptu   (i)     roptu1-roptu14;
array hrrop_1 (i)     hrrop11 hrrop21 hrrop31 hrrop41 hrrop51 hrrop61 hrrop71 hrrop81 hrrop91 hrrop101 hrrop111 hrrop121 hrrop131 hrrop141;
array hrrop_2 (i)     hrrop12 hrrop22 hrrop32 hrrop42 hrrop52 hrrop62 hrrop72 hrrop82 hrrop92 hrrop102 hrrop112 hrrop122 hrrop132 hrrop142;
array hrrop_3 (i)     hrrop13 hrrop23 hrrop33 hrrop43 hrrop53 hrrop63 hrrop73 hrrop83 hrrop93 hrrop103 hrrop113 hrrop123 hrrop133 hrrop143;
array hrrop_4 (i)     hrrop14 hrrop24 hrrop34 hrrop44 hrrop54 hrrop64 hrrop74 hrrop84 hrrop94 hrrop104 hrrop114 hrrop124 hrrop134 hrrop144;
array hrrop_5 (i)     hrrop15 hrrop25 hrrop35 hrrop45 hrrop55 hrrop65 hrrop75 hrrop85 hrrop95 hrrop105 hrrop115 hrrop125 hrrop135 hrrop145;
array wkrop_1 (i)     wkrop11 wkrop21 wkrop31 wkrop41 wkrop51 wkrop61 wkrop71 wkrop81 wkrop91 wkrop101 wkrop111 wkrop121 wkrop131 wkrop141;
array wkrop_2 (i)     wkrop12 wkrop22 wkrop32 wkrop42 wkrop52 wkrop62 wkrop72 wkrop82 wkrop92 wkrop102 wkrop112 wkrop122 wkrop132 wkrop142;
array wkrop_3 (i)     wkrop13 wkrop23 wkrop33 wkrop43 wkrop53 wkrop63 wkrop73 wkrop83 wkrop93 wkrop103 wkrop113 wkrop123 wkrop133 wkrop143;
array wkrop_4 (i)     wkrop14 wkrop24 wkrop34 wkrop44 wkrop54 wkrop64 wkrop74 wkrop84 wkrop94 wkrop104 wkrop114 wkrop124 wkrop134 wkrop144;
array wkrop_5 (i)     wkrop15 wkrop25 wkrop35 wkrop45 wkrop55 wkrop65 wkrop75 wkrop85 wkrop95 wkrop105 wkrop115 wkrop125 wkrop135 wkrop145;
array wkrop_6 (i)     wkrop16 wkrop26 wkrop36 wkrop46 wkrop56 wkrop66 wkrop76 wkrop86 wkrop96 wkrop106 wkrop116 wkrop126 wkrop136 wkrop146;
array morop_1 (i)     morop11 morop21 morop31 morop41 morop51 morop61 morop71 morop81 morop91 morop101 morop111 morop121 morop131 morop141;
array morop_2 (i)     morop12 morop22 morop32 morop42 morop52 morop62 morop72 morop82 morop92 morop102 morop112 morop122 morop132 morop142;
array morop_3 (i)    morop13 morop23 morop33 morop43 morop53 morop63 morop73 morop83 morop93 morop103 morop113 morop123 morop133 morop143;
array morop_4 (i)     morop14 morop24 morop34 morop44 morop54 morop64 morop74 morop84 morop94 morop104 morop114 morop124 morop134 morop144;
array morop_6 (i)    morop16 morop26 morop36 morop46 morop56 morop66 morop76 morop86 morop96 morop106 morop116 morop126 morop136 morop146;
array yrrop_1 (i)     yrrop11 yrrop21 yrrop31 yrrop41 yrrop51 yrrop61 yrrop71 yrrop81 yrrop91 yrrop101 yrrop111 yrrop121 yrrop131 yrrop141;
array yrrop_2 (i)     yrrop12 yrrop22 yrrop32 yrrop42 yrrop52 yrrop62 yrrop72 yrrop82 yrrop92 yrrop102 yrrop112 yrrop122 yrrop132 yrrop142;
array yrrop_3 (i)     yrrop13 yrrop23 yrrop33 yrrop43 yrrop53 yrrop63 yrrop73 yrrop83 yrrop93 yrrop103 yrrop113 yrrop123 yrrop133 yrrop143;
array yrrop_4 (i)     yrrop14 yrrop24 yrrop34 yrrop44 yrrop54 yrrop64 yrrop74 yrrop84 yrrop94 yrrop104 yrrop114 yrrop124 yrrop134 yrrop144;
array yrrop_5 (i)     yrrop15 yrrop25 yrrop35 yrrop45 yrrop55 yrrop65 yrrop75 yrrop85 yrrop95 yrrop105 yrrop115 yrrop125 yrrop135 yrrop145;
array yrrop_6 (i)     yrrop16 yrrop26 yrrop36 yrrop46 yrrop56 yrrop66 yrrop76 yrrop86 yrrop96 yrrop106 yrrop116 yrrop126 yrrop136 yrrop146;
array bwrop_1 (i)     bwrop11 bwrop21 bwrop31 bwrop41 bwrop51 bwrop61 bwrop71 bwrop81 bwrop91 bwrop101 bwrop111 bwrop121 bwrop131 bwrop141;
array bwrop_2 (i)     bwrop12 bwrop22 bwrop32 bwrop42 bwrop52 bwrop62 bwrop72 bwrop82 bwrop92 bwrop102 bwrop112 bwrop122 bwrop132 bwrop132;
array bwrop_3 (i)     bwrop13 bwrop23 bwrop33 bwrop43 bwrop53 bwrop63 bwrop73 bwrop83 bwrop93 bwrop103 bwrop113 bwrop123 bwrop133 bwrop143;
array bwrop_4 (i)     bwrop14 bwrop24 bwrop34 bwrop44 bwrop54 bwrop64 bwrop74 bwrop84 bwrop94 bwrop104 bwrop114 bwrop124 bwrop134 bwrop144;

do i = 1 to 14;
  payrate=-4;
end;

do i = 1 to 14;
  if jobtyp ~= 3 & tregsc ~= 1 then do;
    if (roptu = 1 & hrrop_5 > 0) then payrate=hrrop_5;
    else if (roptu = 1 & hrrop_5 > -4 & hrrop_5 < 0) then payrate=hrrop_5;
    else if (roptu = 1 & hrrop_4 > 0) then payrate=hrrop_4;
    else if (roptu = 1 & hrrop_4 > -4 & hrrop_4 < 0) then payrate=hrrop_4;
    else if (roptu = 1 & hrrop_3 > 0) then payrate=hrrop_3;
    else if (roptu = 1 & hrrop_3 > -4 & hrrop_3 < 0) then payrate=hrrop_3;
    else if (roptu = 1 & hrrop_2 > 0) then payrate=hrrop_2;
    else if (roptu = 1 & hrrop_2 > -4 & hrrop_2 < 0) then payrate=hrrop_2;
    else if (roptu = 1 & hrrop_1 > 0) then payrate=hrrop_1;
    else if (roptu = 1 & hrrop_1 > -4 & hrrop_1 < 0) then payrate=hrrop_1;
    else if (roptu = 1 & hrrop_5 = 0 & hrrop_4 = 0
          & hrrop_3 = 0 & hrrop_2 = 0 & hrrop_1 = 0) then payrate=-4;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_6 > 0)
          then payrate=wkrop_6;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_6 > -4
          & wkrop_6 < 0) then payrate=wkrop_6;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_5 > 0)
          then payrate=wkrop_5;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_5 > -4
          & wkrop_5 < 0) then payrate=wkrop_5;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_4 > 0)
          then payrate=wkrop_4;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_4 > -4
          & wkrop_4 < 0) then payrate=wkrop_4;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_3 > 0)
          then payrate=wkrop_3;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_3 > -4
          & wkrop_3 < 0) then payrate=wkrop_3;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_2 > 0)
          then payrate=wkrop_2;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_2 > -4
          & wkrop_2 < 0) then payrate=wkrop_2;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_1 > 0)
          then payrate=wkrop_1;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_1 > -4
          & wkrop_1 < 0) then payrate=wkrop_1;
    else if ((roptu = 2 | roptu = 3 | roptu = 7) & wkrop_6 = 0
          & wkrop_5 = 0 & wkrop_4 = 0 & wkrop_3 = 0 & wkrop_2 = 0
          & wkrop_1 = 0) then payrate=-4;
    else if ((roptu = 5 | roptu = 8) & morop_6 > 0) then payrate=morop_6;
    else if ((roptu = 5 | roptu = 8) & morop_6 > -4 & morop_6 < 0)
          then payrate=morop_6;
    else if ((roptu = 5 | roptu = 8) & morop_4 > 0) then payrate=morop_4;
    else if ((roptu = 5 | roptu = 8) & morop_4 > -4 & morop_4 < 0)
          then payrate=morop_4;
    else if ((roptu = 5 | roptu = 8) & morop_3 > 0) then payrate=morop_3;
    else if ((roptu = 5 | roptu = 8) & morop_3 > -4 & morop_3 < 0)
          then payrate=morop_3;
    else if ((roptu = 5 | roptu = 8) & morop_2 > 0) then payrate=morop_2;
    else if ((roptu = 5 | roptu = 8) & morop_2 > -4 & morop_2 < 0)
          then payrate=morop_2;
    else if ((roptu = 5 | roptu = 8) & morop_1 > 0) then payrate=morop_1;
    else if ((roptu = 5 | roptu = 8) & morop_1 > -4 & morop_1 < 0)
          then payrate=morop_1;
    else if ((roptu = 5 | roptu = 8) & morop_6 = 0 &
           morop_4 = 0 & morop_3 = 0
          & morop_2 = 0 & morop_1 = 0) then payrate=-4;
    else if ((roptu = 6) & yrrop_6 > -4) then payrate=yrrop_6;
    else if ((roptu = 6) & yrrop_6 > -4 & yrrop_6 < 0) then payrate=yrrop_6;
    else if ((roptu = 6) & yrrop_5 > -4) then payrate=yrrop_5;
    else if ((roptu = 6) & yrrop_5 > -4 & yrrop_5 < 0) then payrate=yrrop_5;
    else if ((roptu = 6) & yrrop_4 > -4) then payrate=yrrop_4;
    else if ((roptu = 6) & yrrop_4 > -4 & yrrop_4 < 0) then payrate=yrrop_4;
    else if ((roptu = 6) & yrrop_3 > -4) then payrate=yrrop_3;
    else if ((roptu = 6) & yrrop_3 > -4 & yrrop_3 < 0) then payrate=yrrop_3;
    else if ((roptu = 6) & yrrop_2 > -4) then payrate=yrrop_2;
    else if ((roptu = 6) & yrrop_2 > -4 & yrrop_2 < 0) then payrate=yrrop_2;
    else if ((roptu = 6) & yrrop_1 > -4) then payrate=yrrop_1;
    else if ((roptu = 6) & yrrop_1 > -4 & yrrop_1 < 0) then payrate=yrrop_1;
    else if ((roptu = 6) & yrrop_6 = 0 & yrrop_5 = 0
          & yrrop_4 = 0 & yrrop_3 = 0 & yrrop_2 = 0 & yrrop_1 = 0)
          then payrate=-4;
    else if ((roptu = 4) & bwrop_4 > -4) then payrate=bwrop_4;
    else if ((roptu = 4) & bwrop_4 > -4 & bwrop_4 < 0) then payrate=bwrop_4;
    else if ((roptu = 4) & bwrop_3 > -4) then payrate=bwrop_3;
    else if ((roptu = 4) & bwrop_3 > -4 & bwrop_3 < 0) then payrate=bwrop_3;
    else if ((roptu = 4) & bwrop_2 > -4) then payrate=bwrop_2;
    else if ((roptu = 4) & bwrop_2 > -4 & bwrop_2 < 0) then payrate=bwrop_2;
    else if ((roptu = 4) & bwrop_1 > -4) then payrate=bwrop_1;
    else if ((roptu = 4) & bwrop_1 > -4 & bwrop_1 < 0) then payrate=bwrop_1;
    else if ((roptu = 4) 
          & bwrop_4 = 0 & bwrop_3 = 0 & bwrop_2 = 0 & bwrop_1 = 0)
          then payrate=-4;
    else if (crwkemp = -4) then payrate=-4;
    else payrate=-3;
  end;
end;

do i = 1 to 14;
    if roptu = 8 & payrate>0 then payrate=payrate/2; 
end;

**************************************************;
**************************************************;
* COMPUTE SELF-EMPLOYMENT RATE OF PAY--YEARLY ONLY;
**************************************************;
**************************************************;
array seyrop  (i) seyrop1-seyrop14;

do i = 1 to 14;
  if jobtyp=3 then do;
    if seyrop > 0 then payrate=(seyrop*100);
    else if -4<seyrop<=0 then payrate=seyrop;
    else if crwkemp=-4 then payrate=-4 ;
    else payrate=-3 ;
    if payrate>-4 then roptu=6;  
  end;
end;

***********************************************************;
***********************************************************;
*       COMPUTE TEACHER RATE OF PAY--YEARLY ONLY           ;
* CANNOT CALCULATE FOR TEACHERS PAID PER COURSE IN ROUND 28;
***********************************************************;
***********************************************************;
array tyrop   (i) tyrop1-tyrop14;
array tapay_1 (i) tapay11 tapay21 tapay31 tapay41 tapay51 tapay61 tapay71 tapay81 tapay91 tapay101 tapay111 tapay121 tapay131 tapay141;
array tapay_2 (i) tapay12 tapay22 tapay32 tapay42 tapay52 tapay62 tapay72 tapay82 tapay92 tapay102 tapay112 tapay122 tapay132 tapay142;
array tapay_3 (i) tapay13 tapay23 tapay33 tapay43 tapay53 tapay63 tapay73 tapay83 tapay93 tapay103 tapay113 tapay123 tapay133 tapay143;
array pay     (i) pay1-pay14;

do i = 1 to 14;
  if tregsc=1 & tcspay ~= 1 then do;
    if tadapt in (-4,0) & tyrop >-4 then payrate=tyrop;
    else if tadapt=1 & tyrop >=0 then do;
      if tapay_1 >= 0 & tapay_2 >= 0 & tapay_3 >= 0 then do;
           payrate=tyrop + tapay_1 + tapay_2 + tapay_3;
      end;
      if tapay_1 >= 0 & tapay_2 >= 0 & tapay_3 < 0 then do;
           payrate=tyrop + tapay_1 + tapay_2;
      end;
      if tapay_1 >= 0 & tapay_2 < 0 & tapay_3 < 0 then do;
           payrate=tyrop + tapay_1;
      end;
      if tapay_1 in (-1,-2,-3) then payrate=tapay_1;
      if tapay_2 in (-1,-2,-3) then payrate=tapay_2;
      if tapay_3 in (-1,-2,-3) then payrate=tapay_3;
    end;
    else if tadapt=1 & tyrop in (-1,-2,-3) then payrate=tyrop;
    else if crwkemp = -4 then payrate=-4;
    else payrate=-3;
    if payrate>-4 then roptu=6;
  end;
end;

do i = 1 to 14;
  if tcspay=1 & payrate <= 0 then do;
    payrate=-3;
    roptu=-3;
  end;
end;

***********************************************************;
***********************************************************;
*  compute non-traditional job rate of pay--monthly only   ;
***********************************************************;
***********************************************************;
array ntmrop  (i)     ntmrop1-ntmrop14;

do i = 1 to 14;
  pay=-4;
end;

do i = 1 to 14;
  if jobtyp=2 then do;
    if ntmrop > -4 then pay=ntmrop;
    else if crwkemp=-4 then pay=-4;
    else pay=-3;
    if pay>0 then do;
      payrate=pay;
      roptu=5;
    end;
  end;
end;

do i = 1 to 14;
    if roptu~=-4 & payrate=-4 then payrate=-3;
end;
*********************************************************************************************;
*********************************************************************************************;
* gaps for non-traditional job holders;
* if number is ge 5, then rs only report longest and most recent gap;
* fill in gap dates in vars for regular job holder gaps--first gap=recent, second gap=longest;
* rs reporting lt 5 gaps go through regular loops;
*********************************************************************************************;
*********************************************************************************************;

array ntsrgd   (i)     ntsrgd1-ntsrgd14;
array ntsrgm   (i)     ntsrgm1-ntsrgm14;
array ntsrgy   (i)     ntsrgy1-ntsrgy14;
array ntergd   (i)     ntergd1-ntergd14;
array ntergm   (i)     ntergm1-ntergm14;
array ntergy   (i)     ntergy1-ntergy14;
array ntslgd   (i)     ntslgd1-ntslgd14;
array ntslgm   (i)     ntslgm1-ntslgm14;
array ntslgy   (i)     ntslgy1-ntslgy14;
array ntelgd   (i)     ntelgd1-ntelgd14;
array ntelgm   (i)     ntelgm1-ntelgm14;
array ntelgy   (i)     ntelgy1-ntelgy14;
array ntngap   (i)     ntngap1-ntngap14;
array stawg_1d (i)     stawg11d stawg21d stawg31d stawg41d stawg51d stawg61d stawg71d stawg81d stawg91d stawg101d stawg111d stawg121d stawg131d stawg141d;
array stawg_1m (i)     stawg11m stawg21m stawg31m stawg41m stawg51m stawg61m stawg71m stawg81m stawg91m stawg101m stawg111m stawg121m stawg131m stawg141m;
array stawg_1y (i)     stawg11y stawg21y stawg31y stawg41y stawg51y stawg61y stawg71y stawg81y stawg91y stawg101y stawg111y stawg121y stawg131y stawg141y;
array stowg_1d (i)     stowg11d stowg21d stowg31d stowg41d stowg51d stowg61d stowg71d stowg81d stowg91d stowg101d stowg111d stowg121d stowg131d stowg141d;
array stowg_1m (i)     stowg11m stowg21m stowg31m stowg41m stowg51m stowg61m stowg71m stowg81m stowg91m stowg101m stowg111m stowg121m stowg131m stowg141m;
array stowg_1y (i)     stowg11y stowg21y stowg31y stowg41y stowg51y stowg61y stowg71y stowg81y stowg91y stowg101y stowg111y stowg121y stowg131y stowg141y;
array stawg_2d (i)     stawg12d stawg22d stawg32d stawg42d stawg52d stawg62d stawg72d stawg82d stawg92d stawg102d stawg112d stawg122d stawg132d stawg142d;
array stawg_2m (i)     stawg12m stawg22m stawg32m stawg42m stawg52m stawg62m stawg72m stawg82m stawg92m stawg102m stawg112m stawg122m stawg132m stawg142m;
array stawg_2y (i)     stawg12y stawg22y stawg32y stawg42y stawg52y stawg62y stawg72y stawg82y stawg92y stawg102y stawg112y stawg122y stawg132y stawg142y;
array stowg_2d (i)     stowg12d stowg22d stowg32d stowg42d stowg52d stowg62d stowg72d stowg82d stowg92d stowg102d stowg112d stowg122d stowg132d stowg142d;
array stowg_2m (i)     stowg12m stowg22m stowg32m stowg42m stowg52m stowg62m stowg72m stowg82m stowg92m stowg102m stowg112m stowg122m stowg132m stowg142m;
array stowg_2y (i)     stowg12y stowg22y stowg32y stowg42y stowg52y stowg62y stowg72y stowg82y stowg92y stowg102y stowg112y stowg122y stowg132y stowg142y;
array stawg_3d (i)     stawg13d stawg23d stawg33d stawg43d stawg53d stawg63d stawg73d stawg83d stawg93d stawg103d stawg113d stawg123d stawg133d stawg143d;
array stawg_3m (i)     stawg13m stawg23m stawg33m stawg43m stawg53m stawg63m stawg73m stawg83m stawg93m stawg103m stawg113m stawg123m stawg133m stawg143m;
array stawg_3y (i)     stawg13y stawg23y stawg33y stawg43y stawg53y stawg63y stawg73y stawg83y stawg93y stawg103y stawg113y stawg123y stawg133y stawg143y;
array stowg_3d (i)     stowg13d stowg23d stowg33d stowg43d stowg53d stowg63d stowg73d stowg83d stowg93d stowg103d stowg113d stowg123d stowg133d stowg143d;
array stowg_3m (i)     stowg13m stowg23m stowg33m stowg43m stowg53m stowg63m stowg73m stowg83m stowg93m stowg103m stowg113m stowg123m stowg133m stowg143m;
array stowg_3y (i)     stowg13y stowg23y stowg33y stowg43y stowg53y stowg63y stowg73y stowg83y stowg93y stowg103y stowg113y stowg123y stowg133y stowg143y;
array stawg_4d (i)     stawg14d stawg24d stawg34d stawg44d stawg54d stawg64d stawg74d stawg84d stawg94d stawg104d stawg114d stawg124d stawg134d stawg144d;
array stawg_4m (i)     stawg14m stawg24m stawg34m stawg44m stawg54m stawg64m stawg74m stawg84m stawg94m stawg104m stawg114m stawg124m stawg134m stawg144m;
array stawg_4y (i)     stawg14y stawg24y stawg34y stawg44y stawg54y stawg64y stawg74y stawg84y stawg94y stawg104y stawg114y stawg124y stawg134y stawg144y;
array stowg_4d (i)     stowg14d stowg24d stowg34d stowg44d stowg54d stowg64d stowg74d stowg84d stowg94d stowg104d stowg114d stowg124d stowg134d stowg144d;
array stowg_4m (i)     stowg14m stowg24m stowg34m stowg44m stowg54m stowg64m stowg74m stowg84m stowg94m stowg104m stowg114m stowg124m stowg134m stowg144m;
array stowg_4y (i)     stowg14y stowg24y stowg34y stowg44y stowg54y stowg64y stowg74y stowg84y stowg94y stowg104y stowg114y stowg124y stowg134y stowg144y;

do i = 1 to 14;
  if ntngap=2 then do;
    stawg_1d=ntsrgd;
    stawg_1m=ntsrgm;
    stawg_1y=ntsrgy;
    stowg_1d=ntergd;
    stowg_1m=ntergm;
    stowg_1y=ntergy;
    stawg_2d=ntslgd;
    stawg_2m=ntslgm;
    stawg_2y=ntslgy;
    stowg_2d=ntelgd;
    stowg_2m=ntelgm;
    stowg_2y=ntelgy;
  end;
end;

*****************************************;
*****************************************;
*FIX CASES WITH PROBLEMATIC SKIP PATTERNS;
*****************************************;
*****************************************;
do i = 1 to 14;
  if tcspay=1 then hrswk=-3;
end;

do i = 1 to 14;
  if tadapt=1 and tapay_1=-4 then payrate=-3;
  if tadapt=1 and tadwk_1=-4 then hrswk=-3;
end;

********************;
********************;
*check teacher hours;
********************;
********************;
array teach   (i)     teach1-teach14;
array thr     (i)     thr1-thr14;
array thrflg  (i)     thrflg1-thrflg14;

do i = 1 to 14;
  thr1=0;
end;

do i = 1 to 14;
  if teach=1 then do;
    if tadapt ~= 1 then do;
      if thrswk>0 & hrwkuhm=thrswk then thr=1;
      if thrswk>0 & hrswku=thrswk then thr=1;
    end;
    if tadapt=1 then do;
      if thrswk>0 & hrwkuhm=hrswk then thr=1;
      if thrswk>0 & hrswku=hrswk then thr=1;
    end;
  end;
end;

do i = 1 to 14;
  thrflg=0;
end;

do i = 1 to 14;
  if thrswk > 0 & tadapt ~= 1 then do;
    if hrwkuhm>0 & hrwkuhm ~= thrswk then thrflg=1;
    if hrwkuhm <= 0 & hrswku ~= thrswk then thrflg=1;
  end;
end;
run;

COW_1994_2022.SAS

Pubid                CASEID
 Norcid            NORCID
1994 variables (1-5)
 previd##1994        EMP##PREVID
 cow##1994            COWALL-EMP.##
 lintday1994            LINTDATE~D
 lintmo1994            LINTDATE~M
 lintyr1994            LINTDATE~Y
1996 variables (1-5)
 previd##1996        EMP##PREVID
 cow##1996            COWALL-EMP.##
 lintday1996            LINTDATE~D
 lintmo1996            LINTDATE~M
 lintyr1996            LINTDATE~Y
1998 variables (1-5)
 lintday1998            LINTDATE~D
 lintmo1998            LINTDATE~M
 lintyr1998            LINTDATE~Y
 previd##1998        EMPPREVID.##
 cow##1998            COWALL-EMP.##
2000 variables (1-5)
 previd##2000        EMPPREVID.##
 cow##2000            COWALL-EMP.##
 lintday2000            LINTDATE~D
 lintmo2000            LINTDATE~M
 lintyr2000            LINTDATE~Y
2002 variables (1-5)
 previd##2002        EMPPREVID.##
 cow##2002            COWALL-EMP.##
 lintday2002            LINTDATE~D
 lintmo2002            LINTDATE~M
 lintyr2002            LINTDATE~Y
2004 variables (1-5)
 previd##2004        EMPPREVID.##
 cow##2004            COWALL-EMP.##
 lintday2004            LINTDATE~D
 lintmo2004            LINTDATE~M
 lintyr2004            LINTDATE~Y
2006 variables (1-5)
 previd##2006        EMPPREVID.##
 cow##2006            COWALL-EMP.##
 lintday2006            LINTDATE~D
 lintmo2006            LINTDATE~M
 lintyr2006            LINTDATE~Y
 cowrev##2006        COWALL-EMP_REVISED.##
2008 variables
 cow##2008            COWALL-EMP.##(1-5)
 lintday2008            LINTDATE~D
 lintmo2008            LINTDATE~M
 lintyr2008            LINTDATE~Y
 previd##2008        EMPLOYER_EMPPREVID.## (1-11)
2010 variables
 lintday2010            LINTDATE~D
 lintmo2010            LINTDATE~M
 lintyr2010            LINTDATE~Y
 cow##2010            COWALL-EMP.## (1-5)
 previd##2010        EMPLOYER_EMPPREVID.## (1-10)
2012 variables
 cow##2012            COWALL-EMP.## (1-5)
 previd##2012        EMPLOYER_EMPPREVID.## (1-9)
 lintday2012            LINTDATE~D
 lintmo2012            LINTDATE~M
 lintyr2012            LINTDATE~Y
2014 variables
 lintday2014            SYMBOL_LINTDATE~D
 lintmo2014            SYMBOL_LINTDATE~M
 lintyr2014            SYMBOL_LINTDATE~Y
 previd#2014            EMPLOYER_EMPPREVID.## (1-7)
2016 variables
 lintday2016            SYMBOL_LINTDATE~D
 lintmo2016            SYMBOL_LINTDATE~M
 lintyr2016            SYMBOL_LINTDATE~Y
 previd##2016        EMPLOYER_EMPPREVID.## (1-8)
2018 variables
 lintday2018            SYMBOL_LINTDATE~D
 lintmo2018            SYMBOL_LINTDATE~M
 lintyr2018            SYMBOL_LINTDATE~Y
 previd##2018        EMPLOYER_EMPPREVID.## (1-9)
2020 variables
 lintday2020            SYMBOL_LINTDATE~D
 lintmo2020            SYMBOL_LINTDATE~M
 lintyr2020            SYMBOL_LINTDATE~Y
 previd##2020        EMPLOYER_EMPPREVID.## (1-6, 13)

array cow     (i) cow1-cow14;
array cowf    (i) cow12022 cow22022 cow32022 cow42022 cow52022 cow62022 cow72022 cow82022 cow92022 cow102022
                  cow112022 cow122022 cow132022 cow142022;
do i = 1 to 14;
   if lintyr2022=. then cow=-5;
   cowf=cow;
end;

lastint2022=0;
if (lintyr2020 > -4) then lastint2022=2020;
else if (lintyr2018 > -4) then lastint2022=2018;
else if (lintyr2016 > -4) then lastint2022=2016;
else if (lintyr2014 > -4) then lastint2022=2014;
else if (lintyr2012 > -4) then lastint2022=2012;
else if (lintyr2010 > -4) then lastint2022=2010;
else if (lintyr2008 > -4) then lastint2022=2008;
else if (lintyr2006 > -4) then lastint2022=2006;
else if (lintyr2004 > -4) then lastint2022=2004;
else if (lintyr2002 > -4) then lastint2022=2002;
else if (lintyr2000 > -4) then lastint2022=2000;
else if (lintyr1998 > -4) then lastint2022=1998;
else if (lintyr1996 > -4) then lastint2022=1996;
else if (lintyr1994 > -4) then lastint2022=1994;
%macro att(yrb);
%do l=1 %to 14;
    %do a=1 %to 13;
        if cow&l.2022 ~= 0 then cow&l.2022_fixed = cow&l.2022;
        else if cow&l.2022 = 0 then do;
            if lastint2022=&yrb & previd&l.2022=&a then do;
                if cow&a&yrb>0|cow&a&yrb=-3|cow&a&yrb=-2|cow&a&yrb=-1 then cow&l.2022_fixed=cow&a&yrb;
                else if cow&a&yrb=0 then cow&l.2022_fixed=-3;
                else if cow&a&yrb=-4 then cow&l.2022_fixed=-4;
            end;
            else if lastint2022=&yrb & previd&l.2022=-4 then cow&l.2022_fixed=-4;
            else if lastint2022=0 then cow&l.2022_fixed=-3;
        end;
    %end;
%end;
%mend att;
%macro rd;
   %do yrb = 2020 %to 1994 %by -2;
       %att(&yrb);
   %end; 
%mend rd;
%rd;
run;

ES_MERGE_2022.SAS

Input from ES_EXTRACT_2022_ORACLE.SAS (see above)

array esallnum         _NUMERIC_;
do over esallnum;
    if missing(esallnum) then esallnum=-4;
end;
array esallchar     _CHARACTER_;
do over esallchar;
    if missing(esallchar) then esallchar=' ';
end;
survyr = 2022;    
q4_12a = -4;
weight22=0;
if INT_D>0 then weight22=1;  
weight=weight22;
if weight = 0 then do;
      q4_c        =-5;
      miloutli    =-5;
      milinli     =-5;
      q4_3        =-5;
      amilcrli    =-5;
      q4_6_m      =-5;
      q4_6_y      =-5;
      miloutd1    =-5;
      miloutm1    =-5;
      milouty1    =-5;
      milsinli    =-5;
      q4_9a_a     =-5;
      mlsinli2    =-5;
      mlsinli3    =-5;
      mlsinli4    =-5;
      mlsinli5    =-5;
      crmlsnli    =-5;
      amilsnli    =-5;
      q4_11a_m    =-5;
      q4_11a_y    =-5;
      milind1     =-5;
      milinm1     =-5;
      miliny1     =-5;
      srvactml    =-5;
      milind2     =-5;
      milinm2     =-5;
      miliny2     =-5;
      milind3     =-5;
      milinm3     =-5;
      miliny3     =-5;
      miloutd2    =-5;
      miloutm2    =-5;
      milouty2    =-5;
      miloutd3    =-5;
      miloutm3    =-5;
      milouty3    =-5;
      q4_28       =-5;
      actmlnow    =-5;
      q7_a        =-5;
      q7_9        =-5;
      stabgpd1    =-5;
      stabgpm1    =-5;
      stabgpy1    =-5;
      stabgpd2    =-5;
      stabgpm2    =-5;
      stabgpy2    =-5;
      stabgpd3    =-5;
      stabgpm3    =-5;
      stabgpy3    =-5;
      stabgpd4    =-5;
      stabgpm4    =-5;
      stabgpy4    =-5;
      stabgpd5    =-5;
      stabgpm5    =-5;
      stabgpy5    =-5;
      stabgpd6    =-5;
      stabgpm6    =-5;
      stabgpy6    =-5;
      stobgpd1    =-5;
      stobgpm1    =-5;
      stobgpy1    =-5;
      stobgpd2    =-5;
      stobgpm2    =-5;
      stobgpy2    =-5;
      stobgpd3    =-5;
      stobgpm3    =-5;
      stobgpy3    =-5;
      stobgpd4    =-5;
      stobgpm4    =-5;
      stobgpy4    =-5;
      stobgpd5    =-5;
      stobgpm5    =-5;
      stobgpy5    =-5;
      stobgpd6    =-5;
      stobgpm6    =-5;
      stobgpy6    =-5;
      wklkbg11    =-5;
      wklkbg21    =-5;
      wklkbg31    =-5;
      wklkbg41    =-5;
      wklkbg51    =-5;
      wklkbg61    =-5;
      q7_15_1     =-5;
      q7_15_2     =-5;
      q7_15_3     =-5;
      q7_15_4     =-5;
      q7_15_5     =-5;
      q7_15_6     =-5;
      wklkbg12    =-5;
      wklkbg22    =-5;
      wklkbg32    =-5;
      wklkbg42    =-5;
      wklkbg52    =-5;
      wklkbg62    =-5;
      q7_17_1     =-5;
      q7_17_2     =-5;
      q7_17_3     =-5;
      q7_17_4     =-5;
      q7_17_5     =-5;
      q7_17_6     =-5;
      ynolkb1g    =-5;
      ynolkb2g    =-5;
      ynolkb3g    =-5;
      ynolkb4g    =-5;
      ynolkb5g    =-5;
      ynolkb6g    =-5;
      JBSTWHN1    =-5;
      JBSTWHN2    =-5;
      JBSTWHN3    =-5;
      JBSTWHN4    =-5;
      JBSTWHN5    =-5;
      JBSTWHN6    =-5;
      JBSTWHN7    =-5;
      JBSTWHN8    =-5;
      JBSTWHN9    =-5;
      JBSTWHN10   =-5;
      JBSTWHN11   =-5;
      JBSTWHN12   =-5;
      JBSTWHN13   =-5;
      JBSTWHN14   =-5;
      MNSB4LI1    =-5;
      MNSB4LI2    =-5;
      MNSB4LI3    =-5;
      MNSB4LI4    =-5;
      MNSB4LI5    =-5;
      MNSB4LI6    =-5;
      MNSB4LI7    =-5;
      MNSB4LI8    =-5;
      MNSB4LI9    =-5;
      MNSB4LI10   =-5;
      MNSB4LI11   =-5;
      MNSB4LI12   =-5;
      MNSB4LI13   =-5;
      MNSB4LI14   =-5;
      CRWKemp1    =-5;
      CRWKemp2    =-5;
      CRWKemp3    =-5;
      CRWKemp4    =-5;
      CRWKemp5    =-5;
      CRWKemp6    =-5;
      CRWKemp7    =-5;
      CRWKemp8    =-5;
      CRWKemp9    =-5;
      CRWKemp10   =-5;
      CRWKemp11   =-5;
      CRWKemp12   =-5;
      CRWKemp13   =-5;
      CRWKemp14   =-5;
      YLFTJOB1    =-5;
      YLFTJOB2    =-5;
      YLFTJOB3    =-5;
      YLFTJOB4    =-5;
      YLFTJOB5    =-5;
      YLFTJOB6    =-5;
      YLFTJOB7    =-5;
      YLFTJOB8    =-5;
      YLFTJOB9    =-5;
      YLFTJOB10   =-5;
      YLFTJOB11   =-5;
      YLFTJOB12   =-5;
      YLFTJOB13   =-5;
      YLFTJOB14   =-5;
      YLFTSEJ1    =-5;
      YLFTSEJ2    =-5;
      YLFTSEJ3    =-5;
      YLFTSEJ4    =-5;
      YLFTSEJ5    =-5;
      YLFTSEJ6    =-5;
      YLFTSEJ7    =-5;
      YLFTSEJ8    =-5;
      YLFTSEJ9    =-5;
      YLFTSEJ10   =-5;
      YLFTSEJ11   =-5;
      YLFTSEJ12   =-5;
      YLFTSEJ13   =-5;
      YLFTSEJ14   =-5;
      ANYWJGP1    =-5;
      ANYWJGP2    =-5;
      ANYWJGP3    =-5;
      ANYWJGP4    =-5;
      ANYWJGP5    =-5;
      ANYWJGP6    =-5;
      ANYWJGP7    =-5;
      ANYWJGP8    =-5;
      ANYWJGP9    =-5;
      ANYWJGP10   =-5;
      ANYWJGP11   =-5;
      ANYWJGP12   =-5;
      ANYWJGP13   =-5;
      ANYWJGP14   =-5;
      STAJOBM1    =-5;
      STAJOBD1    =-5;
      STAJOBY1    =-5;
      STOJOBM1    =-5;
      STOJOBD1    =-5;
      STOJOBY1    =-5;
      STAJOBM2    =-5;
      STAJOBD2    =-5;
      STAJOBY2    =-5;
      STOJOBM2    =-5;
      STOJOBD2    =-5;
      STOJOBY2    =-5;
      STAJOBM3    =-5;
      STAJOBD3    =-5;
      STAJOBY3    =-5;
      STOJOBM3    =-5;
      STOJOBD3    =-5;
      STOJOBY3    =-5;
      STAJOBM4    =-5;
      STAJOBD4    =-5;
      STAJOBY4    =-5;
      STOJOBM4    =-5;
      STOJOBD4    =-5;
      STOJOBY4    =-5;
      STAJOBM5    =-5;
      STAJOBD5    =-5;
      STAJOBY5    =-5;
      STOJOBM5    =-5;
      STOJOBD5    =-5;
      STOJOBY5    =-5;
      STAJOBM6    =-5;
      STAJOBD6    =-5;
      STAJOBY6    =-5;
      STOJOBM6    =-5;
      STOJOBD6    =-5;
      STOJOBY6    =-5;
      STAJOBM7    =-5;
      STAJOBD7    =-5;
      STAJOBY7    =-5;
      STOJOBM7    =-5;
      STOJOBD7    =-5;
      STOJOBY7    =-5;
      STAJOBM8    =-5;
      STAJOBD8    =-5;
      STAJOBY8    =-5;
      STOJOBM8    =-5;
      STOJOBD8    =-5;
      STOJOBY8    =-5;
      STAJOBM9    =-5;
      STAJOBD9    =-5;
      STAJOBY9    =-5;
      STOJOBM9    =-5;
      STOJOBD9    =-5;
      STOJOBY9    =-5;
      STAJOBM10   =-5;
      STAJOBD10   =-5;
      STAJOBY10   =-5;
      STOJOBM10   =-5;
      STOJOBD10   =-5;
      STOJOBY10   =-5;
      STAJOBM11   =-5;
      STAJOBD11   =-5;
      STAJOBY11   =-5;
      STOJOBM11   =-5;
      STOJOBD11   =-5;
      STOJOBY11   =-5;
      STAJOBM12   =-5;
      STAJOBD12   =-5;
      STAJOBY12   =-5;
      STOJOBM12   =-5;
      STOJOBD12   =-5;
      STOJOBY12   =-5;
      STAJOBM13   =-5;
      STAJOBD13   =-5;
      STAJOBY13   =-5;
      STOJOBM13   =-5;
      STOJOBD13   =-5;
      STOJOBY13   =-5;
      STAJOBM14   =-5;
      STAJOBD14   =-5;
      STAJOBY14   =-5;
      STOJOBM14   =-5;
      STOJOBD14   =-5;
      STOJOBY14   =-5;
      STAWG11M    =-5;
      STAWG11D    =-5;
      STAWG11Y    =-5;
      STOWG11M    =-5;
      STOWG11D    =-5;
      STOWG11Y    =-5;
      YNWKG111    =-5;
      YNWKG11C    =-5;
      WKLKG111    =-5;
      WKLKG112    =-5;
      STAWG12M    =-5;
      STAWG12D    =-5;
      STAWG12Y    =-5;
      STOWG12M    =-5;
      STOWG12D    =-5;
      STOWG12Y    =-5;
      YNWKG121    =-5;
      YNWKG12C    =-5;
      WKLKG121    =-5;
      WKLKG122    =-5;
      STAWG13M    =-5;
      STAWG13D    =-5;
      STAWG13Y    =-5;
      STOWG13M    =-5;
      STOWG13D    =-5;
      STOWG13Y    =-5;
      YNWKG131    =-5;
      YNWKG13C    =-5;
      WKLKG131    =-5;
      WKLKG132    =-5;
      STAWG14M    =-5;
      STAWG14D    =-5;
      STAWG14Y    =-5;
      STOWG14M    =-5;
      STOWG14D    =-5;
      STOWG14Y    =-5;
      YNWKG141    =-5;
      YNWKG14C    =-5;
      WKLKG141    =-5;
      WKLKG142    =-5;
      STAWG21D    =-5;
      STAWG21M    =-5;
      STAWG21Y    =-5;
      STOWG21D    =-5;
      STOWG21M    =-5;
      STOWG21Y    =-5;
      YNWKG211    =-5;
      YNWKG21C    =-5;
      WKLKG211    =-5;
      WKLKG212    =-5;
      STAWG22D    =-5;
      STAWG22M    =-5;
      STAWG22Y    =-5;
      STOWG22D    =-5;
      STOWG22M    =-5;
      STOWG22Y    =-5;
      YNWKG221    =-5;
      YNWKG22C    =-5;
      WKLKG221    =-5;
      WKLKG222    =-5;
      STAWG23D    =-5;
      STAWG23M    =-5;
      STAWG23Y    =-5;
      STOWG23D    =-5;
      STOWG23M    =-5;
      STOWG23Y    =-5;
      YNWKG231    =-5;
      YNWKG23C    =-5;
      WKLKG231    =-5;
      WKLKG232    =-5;
      STAWG24D    =-5;
      STAWG24M    =-5;
      STAWG24Y    =-5;
      STOWG24D    =-5;
      STOWG24M    =-5;
      STOWG24Y    =-5;
      YNWKG241    =-5;
      YNWKG24C    =-5;
      WKLKG241    =-5;
      WKLKG242    =-5;
      STAWG31D    =-5;
      STAWG31M    =-5;
      STAWG31Y    =-5;
      STOWG31D    =-5;
      STOWG31M    =-5;
      STOWG31Y    =-5;
      YNWKG311    =-5;
      YNWKG31C    =-5;
      WKLKG311    =-5;
      WKLKG312    =-5;
      STAWG32D    =-5;
      STAWG32M    =-5;
      STAWG32Y    =-5;
      STOWG32D    =-5;
      STOWG32M    =-5;
      STOWG32Y    =-5;
      YNWKG321    =-5;
      YNWKG32C    =-5;
      WKLKG321    =-5;
      WKLKG322    =-5;
      STAWG33D    =-5;
      STAWG33M    =-5;
      STAWG33Y    =-5;
      STOWG33D    =-5;
      STOWG33M    =-5;
      STOWG33Y    =-5;
      YNWKG331    =-5;
      YNWKG33C    =-5;
      WKLKG331    =-5;
      WKLKG332    =-5;
      STAWG34D    =-5;
      STAWG34M    =-5;
      STAWG34Y    =-5;
      STOWG34D    =-5;
      STOWG34M    =-5;
      STOWG34Y    =-5;
      YNWKG341    =-5;
      YNWKG34C    =-5;
      WKLKG341    =-5;
      WKLKG342    =-5;
      STAWG41D    =-5;
      STAWG41M    =-5;
      STAWG41Y    =-5;
      STOWG41D    =-5;
      STOWG41M    =-5;
      STOWG41Y    =-5;
      YNWKG411    =-5;
      YNWKG41C    =-5;
      WKLKG411    =-5;
      WKLKG412    =-5;
      STAWG42D    =-5;
      STAWG42M    =-5;
      STAWG42Y    =-5;
      STOWG42D    =-5;
      STOWG42M    =-5;
      STOWG42Y    =-5;
      YNWKG421    =-5;
      YNWKG42C    =-5;
      WKLKG421    =-5;
      WKLKG422    =-5;
      STAWG43D    =-5;
      STAWG43M    =-5;
      STAWG43Y    =-5;
      STOWG43D    =-5;
      STOWG43M    =-5;
      STOWG43Y    =-5;
      YNWKG431    =-5;
      YNWKG43C    =-5;
      WKLKG431    =-5;
      WKLKG432    =-5;
      STAWG44D    =-5;
      STAWG44M    =-5;
      STAWG44Y    =-5;
      STOWG44D    =-5;
      STOWG44M    =-5;
      STOWG44Y    =-5;
      YNWKG441    =-5;
      YNWKG44C    =-5;
      WKLKG441    =-5;
      WKLKG442    =-5;
      STAWG51D    =-5;
      STAWG51M    =-5;
      STAWG51Y    =-5;
      STOWG51D    =-5;
      STOWG51M    =-5;
      STOWG51Y    =-5;
      YNWKG511    =-5;
      YNWKG51C    =-5;
      WKLKG511    =-5;
      WKLKG512    =-5;
      STAWG52D    =-5;
      STAWG52M    =-5;
      STAWG52Y    =-5;
      STOWG52D    =-5;
      STOWG52M    =-5;
      STOWG52Y    =-5;
      YNWKG521    =-5;
      YNWKG52C    =-5;
      WKLKG521    =-5;
      WKLKG522    =-5;
      STAWG53D    =-5;
      STAWG53M    =-5;
      STAWG53Y    =-5;
      STOWG53D    =-5;
      STOWG53M    =-5;
      STOWG53Y    =-5;
      YNWKG531    =-5;
      YNWKG53C    =-5;
      WKLKG531    =-5;
      WKLKG532    =-5;
      STAWG54D    =-5;
      STAWG54M    =-5;
      STAWG54Y    =-5;
      STOWG54D    =-5;
      STOWG54M    =-5;
      STOWG54Y    =-5;
      YNWKG541    =-5;
      YNWKG54C    =-5;
      WKLKG541    =-5;
      WKLKG542    =-5;
      STAWG61D    =-5;
      STAWG61M    =-5;
      STAWG61Y    =-5;
      STOWG61D    =-5;
      STOWG61M    =-5;
      STOWG61Y    =-5;
      YNWKG611    =-5;
      YNWKG61C    =-5;
      WKLKG611    =-5;
      WKLKG612    =-5;
      STAWG62D    =-5;
      STAWG62M    =-5;
      STAWG62Y    =-5;
      STOWG62D    =-5;
      STOWG62M    =-5;
      STOWG62Y    =-5;
      YNWKG621    =-5;
      YNWKG62C    =-5;
      WKLKG621    =-5;
      WKLKG622    =-5;
      STAWG63D    =-5;
      STAWG63M    =-5;
      STAWG63Y    =-5;
      STOWG63D    =-5;
      STOWG63M    =-5;
      STOWG63Y    =-5;
      YNWKG631    =-5;
      YNWKG63C    =-5;
      WKLKG631    =-5;
      WKLKG632    =-5;
      STAWG64D    =-5;
      STAWG64M    =-5;
      STAWG64Y    =-5;
      STOWG64D    =-5;
      STOWG64M    =-5;
      STOWG64Y    =-5;
      YNWKG641    =-5;
      YNWKG64C    =-5;
      WKLKG641    =-5;
      WKLKG642    =-5;
      STAWG71D    =-5;
      STAWG71M    =-5;
      STAWG71Y    =-5;
      STOWG71D    =-5;
      STOWG71M    =-5;
      STOWG71Y    =-5;
      YNWKG711    =-5;
      YNWKG71C    =-5;
      WKLKG711    =-5;
      WKLKG712    =-5;
      STAWG72D    =-5;
      STAWG72M    =-5;
      STAWG72Y    =-5;
      STOWG72D    =-5;
      STOWG72M    =-5;
      STOWG72Y    =-5;
      YNWKG721    =-5;
      YNWKG72C    =-5;
      WKLKG721    =-5;
      WKLKG722    =-5;
      STAWG73D    =-5;
      STAWG73M    =-5;
      STAWG73Y    =-5;
      STOWG73D    =-5;
      STOWG73M    =-5;
      STOWG73Y    =-5;
      YNWKG731    =-5;
      YNWKG73C    =-5;
      WKLKG731    =-5;
      WKLKG732    =-5;
      STAWG74D    =-5;
      STAWG74M    =-5;
      STAWG74Y    =-5;
      STOWG74D    =-5;
      STOWG74M    =-5;
      STOWG74Y    =-5;
      YNWKG741    =-5;
      YNWKG74C    =-5;
      WKLKG741    =-5;
      WKLKG742    =-5;
      STAWG81D    =-5;
      STAWG81M    =-5;
      STAWG81Y    =-5;
      STOWG81D    =-5;
      STOWG81M    =-5;
      STOWG81Y    =-5;
      YNWKG811    =-5;
      YNWKG81C    =-5;
      WKLKG811    =-5;
      WKLKG812    =-5;
      STAWG82D    =-5;
      STAWG82M    =-5;
      STAWG82Y    =-5;
      STOWG82D    =-5;
      STOWG82M    =-5;
      STOWG82Y    =-5;
      YNWKG821    =-5;
      YNWKG82C    =-5;
      WKLKG821    =-5;
      WKLKG822    =-5;
      STAWG83D    =-5;
      STAWG83M    =-5;
      STAWG83Y    =-5;
      STOWG83D    =-5;
      STOWG83M    =-5;
      STOWG83Y    =-5;
      YNWKG831    =-5;
      YNWKG83C    =-5;
      WKLKG831    =-5;
      WKLKG832    =-5;
      STAWG84D    =-5;
      STAWG84M    =-5;
      STAWG84Y    =-5;
      STOWG84D    =-5;
      STOWG84M    =-5;
      STOWG84Y    =-5;
      YNWKG841    =-5;
      YNWKG84C    =-5;
      WKLKG841    =-5;
      WKLKG842    =-5;
      STAWG91D    =-5;
      STAWG91M    =-5;
      STAWG91Y    =-5;
      STOWG91D    =-5;
      STOWG91M    =-5;
      STOWG91Y    =-5;
      YNWKG911    =-5;
      YNWKG91C    =-5;
      WKLKG911    =-5;
      WKLKG912    =-5;
      STAWG92D    =-5;
      STAWG92M    =-5;
      STAWG92Y    =-5;
      STOWG92D    =-5;
      STOWG92M    =-5;
      STOWG92Y    =-5;
      YNWKG921    =-5;
      YNWKG92C    =-5;
      WKLKG921    =-5;
      WKLKG922    =-5;
      STAWG93D    =-5;
      STAWG93M    =-5;
      STAWG93Y    =-5;
      STOWG93D    =-5;
      STOWG93M    =-5;
      STOWG93Y    =-5;
      YNWKG931    =-5;
      YNWKG93C    =-5;
      WKLKG931    =-5;
      WKLKG932    =-5;
      STAWG94D    =-5;
      STAWG94M    =-5;
      STAWG94Y    =-5;
      STOWG94D    =-5;
      STOWG94M    =-5;
      STOWG94Y    =-5;
      YNWKG941    =-5;
      YNWKG94C    =-5;
      WKLKG941    =-5;
      WKLKG942    =-5;
      STAWG101D   =-5;
      STAWG101M   =-5;
      STAWG101Y   =-5;
      STOWG101D   =-5;
      STOWG101M   =-5;
      STOWG101Y   =-5;
      YNWKG1011   =-5;
      YNWKG101C   =-5;
      WKLKG1011   =-5;
      WKLKG1012   =-5;
      STAWG102D   =-5;
      STAWG102M   =-5;
      STAWG102Y   =-5;
      STOWG102D   =-5;
      STOWG102M   =-5;
      STOWG102Y   =-5;
      YNWKG1021   =-5;
      YNWKG102C   =-5;
      WKLKG1021   =-5;
      WKLKG1022   =-5;
      STAWG103D   =-5;
      STAWG103M   =-5;
      STAWG103Y   =-5;
      STOWG103D   =-5;
      STOWG103M   =-5;
      STOWG103Y   =-5;
      YNWKG1031   =-5;
      YNWKG103C   =-5;
      WKLKG1031   =-5;
      WKLKG1032   =-5;
      STAWG104D   =-5;
      STAWG104M   =-5;
      STAWG104Y   =-5;
      STOWG104D   =-5;
      STOWG104M   =-5;
      STOWG104Y   =-5;
      YNWKG1041   =-5;
      YNWKG104C   =-5;
      WKLKG1041   =-5;
      WKLKG1042   =-5;
      STAWG111D   =-5;
      STAWG111M   =-5;
      STAWG111Y   =-5;
      STOWG111D   =-5;
      STOWG111M   =-5;
      STOWG111Y   =-5;
      YNWKG1111   =-5;
      YNWKG111C   =-5;
      WKLKG1111   =-5;
      WKLKG1112   =-5;
      STAWG112D   =-5;
      STAWG112M   =-5;
      STAWG112Y   =-5;
      STOWG112D   =-5;
      STOWG112M   =-5;
      STOWG112Y   =-5;
      YNWKG1121   =-5;
      YNWKG112C   =-5;
      WKLKG1121   =-5;
      WKLKG1122   =-5;
      STAWG113D   =-5;
      STAWG113M   =-5;
      STAWG113Y   =-5;
      STOWG113D   =-5;
      STOWG113M   =-5;
      STOWG113Y   =-5;
      YNWKG1131   =-5;
      YNWKG113C   =-5;
      WKLKG1131   =-5;
      WKLKG1132   =-5;
      STAWG114D   =-5;
      STAWG114M   =-5;
      STAWG114Y   =-5;
      STOWG114D   =-5;
      STOWG114M   =-5;
      STOWG114Y   =-5;
      YNWKG1141   =-5;
      YNWKG114C   =-5;
      WKLKG1141   =-5;
      WKLKG1142   =-5;
      STAWG121D   =-5;
      STAWG121M   =-5;
      STAWG121Y   =-5;
      STOWG121D   =-5;
      STOWG121M   =-5;
      STOWG121Y   =-5;
      YNWKG1211   =-5;
      YNWKG121C   =-5;
      WKLKG1211   =-5;
      WKLKG1212   =-5;
      STAWG122D   =-5;
      STAWG122M   =-5;
      STAWG122Y   =-5;
      STOWG122D   =-5;
      STOWG122M   =-5;
      STOWG122Y   =-5;
      YNWKG1221   =-5;
      YNWKG122C   =-5;
      WKLKG1221   =-5;
      WKLKG1222   =-5;
      STAWG123D   =-5;
      STAWG123M   =-5;
      STAWG123Y   =-5;
      STOWG123D   =-5;
      STOWG123M   =-5;
      STOWG123Y   =-5;
      YNWKG1231   =-5;
      YNWKG123C   =-5;
      WKLKG1231   =-5;
      WKLKG1232   =-5;
      STAWG124D   =-5;
      STAWG124M   =-5;
      STAWG124Y   =-5;
      STOWG124D   =-5;
      STOWG124M   =-5;
      STOWG124Y   =-5;
      YNWKG1241   =-5;
      YNWKG124C   =-5;
      WKLKG1241   =-5;
      WKLKG1242   =-5;
      STAWG131D   =-5;
      STAWG131M   =-5;
      STAWG131Y   =-5;
      STOWG131D   =-5;
      STOWG131M   =-5;
      STOWG131Y   =-5;
      YNWKG1311   =-5;
      YNWKG131C   =-5;
      WKLKG1311   =-5;
      WKLKG1312   =-5;
      STAWG132D   =-5;
      STAWG132M   =-5;
      STAWG132Y   =-5;
      STOWG132D   =-5;
      STOWG132M   =-5;
      STOWG132Y   =-5;
      YNWKG1321   =-5;
      YNWKG132C   =-5;
      WKLKG1321   =-5;
      WKLKG1322   =-5;
      STAWG133D   =-5;
      STAWG133M   =-5;
      STAWG133Y   =-5;
      STOWG133D   =-5;
      STOWG133M   =-5;
      STOWG133Y   =-5;
      YNWKG1331   =-5;
      YNWKG133C   =-5;
      WKLKG1331   =-5;
      WKLKG1332   =-5;
      STAWG134D   =-5;
      STAWG134M   =-5;
      STAWG134Y   =-5;
      STOWG134D   =-5;
      STOWG134M   =-5;
      STOWG134Y   =-5;
      YNWKG1341   =-5;
      YNWKG134C   =-5;
      WKLKG1341   =-5;
      WKLKG1342   =-5;
      STAWG141D   =-5;
      STAWG141M   =-5;
      STAWG141Y   =-5;
      STOWG141D   =-5;
      STOWG141M   =-5;
      STOWG141Y   =-5;
      YNWKG1411   =-5;
      YNWKG141C   =-5;
      WKLKG1411   =-5;
      WKLKG1412   =-5;
      STAWG142D   =-5;
      STAWG142M   =-5;
      STAWG142Y   =-5;
      STOWG142D   =-5;
      STOWG142M   =-5;
      STOWG142Y   =-5;
      YNWKG1421   =-5;
      YNWKG142C   =-5;
      WKLKG1421   =-5;
      WKLKG1422   =-5;
      STAWG143D   =-5;
      STAWG143M   =-5;
      STAWG143Y   =-5;
      STOWG143D   =-5;
      STOWG143M   =-5;
      STOWG143Y   =-5;
      YNWKG1431   =-5;
      YNWKG143C   =-5;
      WKLKG1431   =-5;
      WKLKG1432   =-5;
      STAWG144D   =-5;
      STAWG144M   =-5;
      STAWG144Y   =-5;
      STOWG144D   =-5;
      STOWG144M   =-5;
      STOWG144Y   =-5;
      YNWKG1441   =-5;
      YNWKG144C   =-5;
      WKLKG1441   =-5;
      WKLKG1442   =-5;
      HRSDAYU1    =-5;
      HRSWKU1     =-5;
      HRWKUHM1    =-5;
      HRWKSEH1    =-5;
      HRSWK1      =-5;
      e_53b_1     =-5;
      e_54b_1     =-5;
      OCCSMLI1    =-5;
      COWNEW1     =-5;
      E1COWCD     =-5;
      HRSDAYU2    =-5;
      HRSWKU2     =-5;
      HRWKUHM2    =-5;
      HRWKSEH2    =-5;
      HRSWK2      =-5;
      e_53b_2     =-5;
      e_54b_2     =-5;
      OCCSMLI2    =-5;
      COWNEW2     =-5;
      E2COWCD     =-5;
      HRSDAYU3    =-5;
      HRSWKU3     =-5;
      HRWKUHM3    =-5;
      HRWKSEH3    =-5;
      HRSWK3      =-5;
      e_53b_3     =-5;
      e_54b_3     =-5;
      OCCSMLI3    =-5;
      COWNEW3     =-5;
      E3COWCD     =-5;
      HRSDAYU4    =-5;
      HRSWKU4     =-5;
      HRWKUHM4    =-5;
      HRWKSEH4    =-5;
      HRSWK4      =-5;
      e_53b_4     =-5;
      e_54b_4     =-5;
      OCCSMLI4    =-5;
      COWNEW4     =-5;
      E4COWCD     =-5;
      HRSDAYU5    =-5;
      HRSWKU5     =-5;
      HRWKUHM5    =-5;
      HRWKSEH5    =-5;
      HRSWK5      =-5;
      e_53b_5     =-5;
      e_54b_5     =-5;
      OCCSMLI5    =-5;
      COWNEW5     =-5;
      E5COWCD     =-5;
      HRSDAYU6    =-5;
      HRSWKU6     =-5;
      HRWKUHM6    =-5;
      HRWKSEH6    =-5;
      HRSWK6      =-5;
      e_53b_6     =-5;
      e_54b_6     =-5;
      OCCSMLI6    =-5;
      COWNEW6     =-5;
      E6COWCD     =-5;
      HRSDAYU7    =-5;
      HRSWKU7     =-5;
      HRWKUHM7    =-5;
      HRWKSEH7    =-5;
      HRSWK7      =-5;
      e_53b_7     =-5;
      e_54b_7     =-5;
      OCCSMLI7    =-5;
      COWNEW7     =-5;
      E7COWCD     =-5;
      HRSDAYU8    =-5;
      HRSWKU8     =-5;
      HRWKUHM8    =-5;
      HRWKSEH8    =-5;
      HRSWK8      =-5;
      e_53b_8     =-5;
      e_54b_8     =-5;
      OCCSMLI8    =-5;
      COWNEW8     =-5;
      E8COWCD     =-5;
      HRSDAYU9    =-5;
      HRSWKU9     =-5;
      HRWKUHM9    =-5;
      HRWKSEH9    =-5;
      HRSWK9      =-5;
      e_53b_9     =-5;
      e_54b_9     =-5;
      OCCSMLI9    =-5;
      COWNEW9     =-5;
      E9COWCD     =-5;
      HRSDAYU10   =-5;
      HRSWKU10    =-5;
      HRWKUHM10   =-5;
      HRWKSEH10   =-5;
      HRSWK10     =-5;
      e_53b_10    =-5;
      e_54b_10    =-5;
      OCCSMLI10   =-5;
      COWNEW10    =-5;
      E10COWCD    =-5;
      HRSDAYU11   =-5;
      HRSWKU11    =-5;
      HRWKUHM11   =-5;
      HRWKSEH11   =-5;
      HRSWK11     =-5;
      e_53b_11    =-5;
      e_54b_11    =-5;
      OCCSMLI11   =-5;
      COWNEW11    =-5;
      E11COWCD    =-5;
      HRSDAYU12   =-5;
      HRSWKU12    =-5;
      HRWKUHM12   =-5;
      HRWKSEH12   =-5;
      HRSWK12     =-5;
      e_53b_12    =-5;
      e_54b_12    =-5;
      OCCSMLI12   =-5;
      COWNEW12    =-5;
      E12COWCD    =-5;
      HRSDAYU13   =-5;
      HRSWKU13    =-5;
      HRWKUHM13   =-5;
      HRWKSEH13   =-5;
      HRSWK13     =-5;
      e_53b_13    =-5;
      e_54b_13    =-5;
      OCCSMLI13   =-5;
      COWNEW13    =-5;
      E13COWCD    =-5;
      HRSDAYU14   =-5;
      HRSWKU14    =-5;
      HRWKUHM14   =-5;
      HRWKSEH14   =-5;
      HRSWK14     =-5;
      e_53b_14    =-5;
      e_54b_14    =-5;
      OCCSMLI14   =-5;
      COWNEW14    =-5;
      E14COWCD    =-5;
      ROPTU1      =-5;
      SEYROP1     =-5;
      TADAPT1     =-5;
      TYROP1      =-5;
      TCSPAY1     =-5;
      TCSROP1     =-5;
      TCSWKS1     =-5;
      TCSHRW1     =-5;
      TCSNUM1     =-5;
      TPEROP1     =-5;
      THRSWK1     =-5;
      TAPAY11     =-5;
      TAPAY12     =-5;
      TAPAY13     =-5;
      TADWK11     =-5;
      TADWK12     =-5;
      TADWK13     =-5;
      TADHR11     =-5;
      TADHR12     =-5;
      TADHR13     =-5;
      NTMROP1     =-5;
      NTNGAP1     =-5;
      NTSRGD1     =-5;
      NTSRGM1     =-5;
      NTSRGY1     =-5;
      NTERGD1     =-5;
      NTERGM1     =-5;
      NTERGY1     =-5;
      NTSLGD1     =-5;
      NTSLGM1     =-5;
      NTSLGY1     =-5;
      NTELGD1     =-5;
      NTELGM1     =-5;
      NTELGY1     =-5;
      HRROP11     =-5;
      HRROP12     =-5;
      HRROP13     =-5;
      HRROP14     =-5;
      HRROP15     =-5;
      WKROP11     =-5;
      WKROP12     =-5;
      WKROP13     =-5;
      WKROP14     =-5;
      WKROP15     =-5;
      WKROP16     =-5;
      MOROP11     =-5;
      MOROP12     =-5;
      MOROP13     =-5;
      MOROP14     =-5;
      MOROP16     =-5;
      YRROP11     =-5;
      YRROP12     =-5;
      YRROP13     =-5;
      YRROP14     =-5;
      YRROP15     =-5;
      YRROP16     =-5;
      BWROP11     =-5;
      BWROP12     =-5;
      BWROP13     =-5;
      BWROP14     =-5;
      PAYRATE1    =-5;
      ROPTU2      =-5;
      SEYROP2     =-5;
      TADAPT2     =-5;
      TYROP2      =-5;
      TCSPAY2     =-5;
      TCSROP2     =-5;
      TCSWKS2     =-5;
      TCSHRW2     =-5;
      TCSNUM2     =-5;
      TPEROP2     =-5;
      THRSWK2     =-5;
      TAPAY21     =-5;
      TAPAY22     =-5;
      TAPAY23     =-5;
      TADWK21     =-5;
      TADWK22     =-5;
      TADWK23     =-5;
      TADHR21     =-5;
      TADHR22     =-5;
      TADHR23     =-5;
      NTMROP2     =-5;
      NTNGAP2     =-5;
      NTSRGD2     =-5;
      NTSRGM2     =-5;
      NTSRGY2     =-5;
      NTERGD2     =-5;
      NTERGM2     =-5;
      NTERGY2     =-5;
      NTSLGD2     =-5;
      NTSLGM2     =-5;
      NTSLGY2     =-5;
      NTELGD2     =-5;
      NTELGM2     =-5;
      NTELGY2     =-5;
      HRROP21     =-5;
      HRROP22     =-5;
      HRROP23     =-5;
      HRROP24     =-5;
      HRROP25     =-5;
      WKROP21     =-5;
      WKROP22     =-5;
      WKROP23     =-5;
      WKROP24     =-5;
      WKROP25     =-5;
      WKROP26     =-5;
      MOROP21     =-5;
      MOROP22     =-5;
      MOROP23     =-5;
      MOROP24     =-5;
      MOROP26     =-5;
      YRROP21     =-5;
      YRROP22     =-5;
      YRROP23     =-5;
      YRROP24     =-5;
      YRROP25     =-5;
      YRROP26     =-5;
      BWROP21     =-5;
      BWROP22     =-5;
      BWROP23     =-5;
      BWROP24     =-5;
      PAYRATE2    =-5;
      ROPTU3      =-5;
      SEYROP3     =-5;
      TADAPT3     =-5;
      TYROP3      =-5;
      TCSPAY3     =-5;
      TCSROP3     =-5;
      TCSWKS3     =-5;
      TCSHRW3     =-5;
      TCSNUM3     =-5;
      TPEROP3     =-5;
      THRSWK3     =-5;
      TAPAY31     =-5;
      TAPAY32     =-5;
      TAPAY33     =-5;
      TADWK31     =-5;
      TADWK32     =-5;
      TADWK33     =-5;
      TADHR31     =-5;
      TADHR32     =-5;
      TADHR33     =-5;
      NTMROP3     =-5;
      NTNGAP3     =-5;
      NTSRGD3     =-5;
      NTSRGM3     =-5;
      NTSRGY3     =-5;
      NTERGD3     =-5;
      NTERGM3     =-5;
      NTERGY3     =-5;
      NTSLGD3     =-5;
      NTSLGM3     =-5;
      NTSLGY3     =-5;
      NTELGD3     =-5;
      NTELGM3     =-5;
      NTELGY3     =-5;
      HRROP31     =-5;
      HRROP32     =-5;
      HRROP33     =-5;
      HRROP34     =-5;
      HRROP35     =-5;
      WKROP31     =-5;
      WKROP32     =-5;
      WKROP33     =-5;
      WKROP34     =-5;
      WKROP35     =-5;
      WKROP36     =-5;
      MOROP31     =-5;
      MOROP32     =-5;
      MOROP33     =-5;
      MOROP34     =-5;
      MOROP36     =-5;
      YRROP31     =-5;
      YRROP32     =-5;
      YRROP33     =-5;
      YRROP34     =-5;
      YRROP35     =-5;
      YRROP36     =-5;
      BWROP31     =-5;
      BWROP32     =-5;
      BWROP33     =-5;
      BWROP34     =-5;
      PAYRATE3    =-5;
      ROPTU4      =-5;
      SEYROP4     =-5;
      TADAPT4     =-5;
      TYROP4      =-5;
      TCSPAY4     =-5;
      TCSROP4     =-5;
      TCSWKS4     =-5;
      TCSHRW4     =-5;
      TCSNUM4     =-5;
      TPEROP4     =-5;
      THRSWK4     =-5;
      TAPAY41     =-5;
      TAPAY42     =-5;
      TAPAY43     =-5;
      TADWK41     =-5;
      TADWK42     =-5;
      TADWK43     =-5;
      TADHR41     =-5;
      TADHR42     =-5;
      TADHR43     =-5;
      NTMROP4     =-5;
      NTNGAP4     =-5;
      NTSRGD4     =-5;
      NTSRGM4     =-5;
      NTSRGY4     =-5;
      NTERGD4     =-5;
      NTERGM4     =-5;
      NTERGY4     =-5;
      NTSLGD4     =-5;
      NTSLGM4     =-5;
      NTSLGY4     =-5;
      NTELGD4     =-5;
      NTELGM4     =-5;
      NTELGY4     =-5;
      HRROP41     =-5;
      HRROP42     =-5;
      HRROP43     =-5;
      HRROP44     =-5;
      HRROP45     =-5;
      WKROP41     =-5;
      WKROP42     =-5;
      WKROP43     =-5;
      WKROP44     =-5;
      WKROP45     =-5;
      WKROP46     =-5;
      MOROP41     =-5;
      MOROP42     =-5;
      MOROP43     =-5;
      MOROP44     =-5;
      MOROP46     =-5;
      YRROP41     =-5;
      YRROP42     =-5;
      YRROP43     =-5;
      YRROP44     =-5;
      YRROP45     =-5;
      YRROP46     =-5;
      BWROP41     =-5;
      BWROP42     =-5;
      BWROP43     =-5;
      BWROP44     =-5;
      PAYRATE4    =-5;
      ROPTU5      =-5;
      SEYROP5     =-5;
      TADAPT5     =-5;
      TYROP5      =-5;
      TCSPAY5     =-5;
      TCSROP5     =-5;
      TCSWKS5     =-5;
      TCSHRW5     =-5;
      TCSNUM5     =-5;
      TPEROP5     =-5;
      THRSWK5     =-5;
      TAPAY51     =-5;
      TAPAY52     =-5;
      TAPAY53     =-5;
      TADWK51     =-5;
      TADWK52     =-5;
      TADWK53     =-5;
      TADHR51     =-5;
      TADHR52     =-5;
      TADHR53     =-5;
      NTMROP5     =-5;
      NTNGAP5     =-5;
      NTSRGD5     =-5;
      NTSRGM5     =-5;
      NTSRGY5     =-5;
      NTERGD5     =-5;
      NTERGM5     =-5;
      NTERGY5     =-5;
      NTSLGD5     =-5;
      NTSLGM5     =-5;
      NTSLGY5     =-5;
      NTELGD5     =-5;
      NTELGM5     =-5;
      NTELGY5     =-5;
      HRROP51     =-5;
      HRROP52     =-5;
      HRROP53     =-5;
      HRROP54     =-5;
      HRROP55     =-5;
      WKROP51     =-5;
      WKROP52     =-5;
      WKROP53     =-5;
      WKROP54     =-5;
      WKROP55     =-5;
      WKROP56     =-5;
      MOROP51     =-5;
      MOROP52     =-5;
      MOROP53     =-5;
      MOROP54     =-5;
      MOROP56     =-5;
      YRROP51     =-5;
      YRROP52     =-5;
      YRROP53     =-5;
      YRROP54     =-5;
      YRROP55     =-5;
      YRROP56     =-5;
      BWROP51     =-5;
      BWROP52     =-5;
      BWROP53     =-5;
      BWROP54     =-5;
      PAYRATE5    =-5;
      ROPTU6      =-5;
      SEYROP6     =-5;
      TADAPT6     =-5;
      TYROP6      =-5;
      TCSPAY6     =-5;
      TCSROP6     =-5;
      TCSWKS6     =-5;
      TCSHRW6     =-5;
      TCSNUM6     =-5;
      TPEROP6     =-5;
      THRSWK6     =-5;
      TAPAY61     =-5;
      TAPAY62     =-5;
      TAPAY63     =-5;
      TADWK61     =-5;
      TADWK62     =-5;
      TADWK63     =-5;
      TADHR61     =-5;
      TADHR62     =-5;
      TADHR63     =-5;
      NTMROP6     =-5;
      NTNGAP6     =-5;
      NTSRGD6     =-5;
      NTSRGM6     =-5;
      NTSRGY6     =-5;
      NTERGD6     =-5;
      NTERGM6     =-5;
      NTERGY6     =-5;
      NTSLGD6     =-5;
      NTSLGM6     =-5;
      NTSLGY6     =-5;
      NTELGD6     =-5;
      NTELGM6     =-5;
      NTELGY6     =-5;
      HRROP61     =-5;
      HRROP62     =-5;
      HRROP63     =-5;
      HRROP64     =-5;
      HRROP65     =-5;
      WKROP61     =-5;
      WKROP62     =-5;
      WKROP63     =-5;
      WKROP64     =-5;
      WKROP65     =-5;
      WKROP66     =-5;
      MOROP61     =-5;
      MOROP62     =-5;
      MOROP63     =-5;
      MOROP64     =-5;
      MOROP66     =-5;
      YRROP61     =-5;
      YRROP62     =-5;
      YRROP63     =-5;
      YRROP64     =-5;
      YRROP65     =-5;
      YRROP66     =-5;
      BWROP61     =-5;
      BWROP62     =-5;
      BWROP63     =-5;
      BWROP64     =-5;
      PAYRATE6    =-5;
      ROPTU7      =-5;
      SEYROP7     =-5;
      TADAPT7     =-5;
      TYROP7      =-5;
      TCSPAY7     =-5;
      TCSROP7     =-5;
      TCSWKS7     =-5;
      TCSHRW7     =-5;
      TCSNUM7     =-5;
      TPEROP7     =-5;
      THRSWK7     =-5;
      TAPAY71     =-5;
      TAPAY72     =-5;
      TAPAY73     =-5;
      TADWK71     =-5;
      TADWK72     =-5;
      TADWK73     =-5;
      TADHR71     =-5;
      TADHR72     =-5;
      TADHR73     =-5;
      NTMROP7     =-5;
      NTNGAP7     =-5;
      NTSRGD7     =-5;
      NTSRGM7     =-5;
      NTSRGY7     =-5;
      NTERGD7     =-5;
      NTERGM7     =-5;
      NTERGY7     =-5;
      NTSLGD7     =-5;
      NTSLGM7     =-5;
      NTSLGY7     =-5;
      NTELGD7     =-5;
      NTELGM7     =-5;
      NTELGY7     =-5;
      HRROP71     =-5;
      HRROP72     =-5;
      HRROP73     =-5;
      HRROP74     =-5;
      HRROP75     =-5;
      WKROP71     =-5;
      WKROP72     =-5;
      WKROP73     =-5;
      WKROP74     =-5;
      WKROP75     =-5;
      WKROP76     =-5;
      MOROP71     =-5;
      MOROP72     =-5;
      MOROP73     =-5;
      MOROP74     =-5;
      MOROP76     =-5;
      YRROP71     =-5;
      YRROP72     =-5;
      YRROP73     =-5;
      YRROP74     =-5;
      YRROP75     =-5;
      YRROP76     =-5;
      BWROP71     =-5;
      BWROP72     =-5;
      BWROP73     =-5;
      BWROP74     =-5;
      PAYRATE7    =-5;
      ROPTU8      =-5;
      SEYROP8     =-5;
      TADAPT8     =-5;
      TYROP8      =-5;
      TCSPAY8     =-5;
      TCSROP8     =-5;
      TCSWKS8     =-5;
      TCSHRW8     =-5;
      TCSNUM8     =-5;
      TPEROP8     =-5;
      THRSWK8     =-5;
      TAPAY81     =-5;
      TAPAY82     =-5;
      TAPAY83     =-5;
      TADWK81     =-5;
      TADWK82     =-5;
      TADWK83     =-5;
      TADHR81     =-5;
      TADHR82     =-5;
      TADHR83     =-5;
      NTMROP8     =-5;
      NTNGAP8     =-5;
      NTSRGD8     =-5;
      NTSRGM8     =-5;
      NTSRGY8     =-5;
      NTERGD8     =-5;
      NTERGM8     =-5;
      NTERGY8     =-5;
      NTSLGD8     =-5;
      NTSLGM8     =-5;
      NTSLGY8     =-5;
      NTELGD8     =-5;
      NTELGM8     =-5;
      NTELGY8     =-5;
      HRROP81     =-5;
      HRROP82     =-5;
      HRROP83     =-5;
      HRROP84     =-5;
      HRROP85     =-5;
      WKROP81     =-5;
      WKROP82     =-5;
      WKROP83     =-5;
      WKROP84     =-5;
      WKROP85     =-5;
      WKROP86     =-5;
      MOROP81     =-5;
      MOROP82     =-5;
      MOROP83     =-5;
      MOROP84     =-5;
      MOROP86     =-5;
      YRROP81     =-5;
      YRROP82     =-5;
      YRROP83     =-5;
      YRROP84     =-5;
      YRROP85     =-5;
      YRROP86     =-5;
      BWROP81     =-5;
      BWROP82     =-5;
      BWROP83     =-5;
      BWROP84     =-5;
      PAYRATE8    =-5;
      ROPTU9      =-5;
      SEYROP9     =-5;
      TADAPT9     =-5;
      TYROP9      =-5;
      TCSPAY9     =-5;
      TCSROP9     =-5;
      TCSWKS9     =-5;
      TCSHRW9     =-5;
      TCSNUM9     =-5;
      TPEROP9     =-5;
      THRSWK9     =-5;
      TAPAY91     =-5;
      TAPAY92     =-5;
      TAPAY93     =-5;
      TADWK91     =-5;
      TADWK92     =-5;
      TADWK93     =-5;
      TADHR91     =-5;
      TADHR92     =-5;
      TADHR93     =-5;
      NTMROP9     =-5;
      NTNGAP9     =-5;
      NTSRGD9     =-5;
      NTSRGM9     =-5;
      NTSRGY9     =-5;
      NTERGD9     =-5;
      NTERGM9     =-5;
      NTERGY9     =-5;
      NTSLGD9     =-5;
      NTSLGM9     =-5;
      NTSLGY9     =-5;
      NTELGD9     =-5;
      NTELGM9     =-5;
      NTELGY9     =-5;
      HRROP91     =-5;
      HRROP92     =-5;
      HRROP93     =-5;
      HRROP94     =-5;
      HRROP95     =-5;
      WKROP91     =-5;
      WKROP92     =-5;
      WKROP93     =-5;
      WKROP94     =-5;
      WKROP95     =-5;
      WKROP96     =-5;
      MOROP91     =-5;
      MOROP92     =-5;
      MOROP93     =-5;
      MOROP94     =-5;
      MOROP96     =-5;
      YRROP91     =-5;
      YRROP92     =-5;
      YRROP93     =-5;
      YRROP94     =-5;
      YRROP95     =-5;
      YRROP96     =-5;
      BWROP91     =-5;
      BWROP92     =-5;
      BWROP93     =-5;
      BWROP94     =-5;
      PAYRATE9    =-5;
      ROPTU10     =-5;
      SEYROP10    =-5;
      TADAPT10    =-5;
      TYROP10     =-5;
      TCSPAY10    =-5;
      TCSROP10    =-5;
      TCSWKS10    =-5;
      TCSHRW10    =-5;
      TCSNUM10    =-5;
      TPEROP10    =-5;
      THRSWK10    =-5;
      TAPAY101    =-5;
      TAPAY102    =-5;
      TAPAY103    =-5;
      TADWK101    =-5;
      TADWK102    =-5;
      TADWK103    =-5;
      TADHR101    =-5;
      TADHR102    =-5;
      TADHR103    =-5;
      NTMROP10    =-5;
      NTNGAP10    =-5;
      NTSRGD10    =-5;
      NTSRGM10    =-5;
      NTSRGY10    =-5;
      NTERGD10    =-5;
      NTERGM10    =-5;
      NTERGY10    =-5;
      NTSLGD10    =-5;
      NTSLGM10    =-5;
      NTSLGY10    =-5;
      NTELGD10    =-5;
      NTELGM10    =-5;
      NTELGY10    =-5;
      HRROP101    =-5;
      HRROP102    =-5;
      HRROP103    =-5;
      HRROP104    =-5;
      HRROP105    =-5;
      WKROP101    =-5;
      WKROP102    =-5;
      WKROP103    =-5;
      WKROP104    =-5;
      WKROP105    =-5;
      WKROP106    =-5;
      MOROP101    =-5;
      MOROP102    =-5;
      MOROP103    =-5;
      MOROP104    =-5;
      MOROP106    =-5;
      YRROP101    =-5;
      YRROP102    =-5;
      YRROP103    =-5;
      YRROP104    =-5;
      YRROP105    =-5;
      YRROP106    =-5;
      BWROP101    =-5;
      BWROP102    =-5;
      BWROP103    =-5;
      BWROP104    =-5;
      PAYRATE10   =-5;
      ROPTU11     =-5;
      SEYROP11    =-5;
      TADAPT11    =-5;
      TYROP11     =-5;
      TCSPAY11    =-5;
      TCSROP11    =-5;
      TCSWKS11    =-5;
      TCSHRW11    =-5;
      TCSNUM11    =-5;
      TPEROP11    =-5;
      THRSWK11    =-5;
      TAPAY111    =-5;
      TAPAY112    =-5;
      TAPAY113    =-5;
      TADWK111    =-5;
      TADWK112    =-5;
      TADWK113    =-5;
      TADHR111    =-5;
      TADHR112    =-5;
      TADHR113    =-5;
      NTMROP11    =-5;
      NTNGAP11    =-5;
      NTSRGD11    =-5;
      NTSRGM11    =-5;
      NTSRGY11    =-5;
      NTERGD11    =-5;
      NTERGM11    =-5;
      NTERGY11    =-5;
      NTSLGD11    =-5;
      NTSLGM11    =-5;
      NTSLGY11    =-5;
      NTELGD11    =-5;
      NTELGM11    =-5;
      NTELGY11    =-5;
      HRROP111    =-5;
      HRROP112    =-5;
      HRROP113    =-5;
      HRROP114    =-5;
      HRROP115    =-5;
      WKROP111    =-5;
      WKROP112    =-5;
      WKROP113    =-5;
      WKROP114    =-5;
      WKROP115    =-5;
      WKROP116    =-5;
      MOROP111    =-5;
      MOROP112    =-5;
      MOROP113    =-5;
      MOROP114    =-5;
      MOROP116    =-5;
      YRROP111    =-5;
      YRROP112    =-5;
      YRROP113    =-5;
      YRROP114    =-5;
      YRROP115    =-5;
      YRROP116    =-5;
      BWROP111    =-5;
      BWROP112    =-5;
      BWROP113    =-5;
      BWROP114    =-5;
      PAYRATE11   =-5;
      ROPTU12     =-5;
      SEYROP12    =-5;
      TADAPT12    =-5;
      TYROP12     =-5;
      TCSPAY12    =-5;
      TCSROP12    =-5;
      TCSWKS12    =-5;
      TCSHRW12    =-5;
      TCSNUM12    =-5;
      TPEROP12    =-5;
      THRSWK12    =-5;
      TAPAY121    =-5;
      TAPAY122    =-5;
      TAPAY123    =-5;
      TADWK121    =-5;
      TADWK122    =-5;
      TADWK123    =-5;
      TADHR121    =-5;
      TADHR122    =-5;
      TADHR123    =-5;
      NTMROP12    =-5;
      NTNGAP12    =-5;
      NTSRGD12    =-5;
      NTSRGM12    =-5;
      NTSRGY12    =-5;
      NTERGD12    =-5;
      NTERGM12    =-5;
      NTERGY12    =-5;
      NTSLGD12    =-5;
      NTSLGM12    =-5;
      NTSLGY12    =-5;
      NTELGD12    =-5;
      NTELGM12    =-5;
      NTELGY12    =-5;
      HRROP121    =-5;
      HRROP122    =-5;
      HRROP123    =-5;
      HRROP124    =-5;
      HRROP125    =-5;
      WKROP121    =-5;
      WKROP122    =-5;
      WKROP123    =-5;
      WKROP124    =-5;
      WKROP125    =-5;
      WKROP126    =-5;
      MOROP121    =-5;
      MOROP122    =-5;
      MOROP123    =-5;
      MOROP124    =-5;
      MOROP126    =-5;
      YRROP121    =-5;
      YRROP122    =-5;
      YRROP123    =-5;
      YRROP124    =-5;
      YRROP125    =-5;
      YRROP126    =-5;
      BWROP121    =-5;
      BWROP122    =-5;
      BWROP123    =-5;
      BWROP124    =-5;
      PAYRATE12   =-5;
      ROPTU13     =-5;
      SEYROP13    =-5;
      TADAPT13    =-5;
      TYROP13     =-5;
      TCSPAY13    =-5;
      TCSROP13    =-5;
      TCSWKS13    =-5;
      TCSHRW13    =-5;
      TCSNUM13    =-5;
      TPEROP13    =-5;
      THRSWK13    =-5;
      TAPAY131    =-5;
      TAPAY132    =-5;
      TAPAY133    =-5;
      TADWK131    =-5;
      TADWK132    =-5;
      TADWK133    =-5;
      TADHR131    =-5;
      TADHR132    =-5;
      TADHR133    =-5;
      NTMROP13    =-5;
      NTNGAP13    =-5;
      NTSRGD13    =-5;
      NTSRGM13    =-5;
      NTSRGY13    =-5;
      NTERGD13    =-5;
      NTERGM13    =-5;
      NTERGY13    =-5;
      NTSLGD13    =-5;
      NTSLGM13    =-5;
      NTSLGY13    =-5;
      NTELGD13    =-5;
      NTELGM13    =-5;
      NTELGY13    =-5;
      HRROP131    =-5;
      HRROP132    =-5;
      HRROP133    =-5;
      HRROP134    =-5;
      HRROP135    =-5;
      WKROP131    =-5;
      WKROP132    =-5;
      WKROP133    =-5;
      WKROP134    =-5;
      WKROP135    =-5;
      WKROP136    =-5;
      MOROP131    =-5;
      MOROP132    =-5;
      MOROP133    =-5;
      MOROP134    =-5;
      MOROP136    =-5;
      YRROP131    =-5;
      YRROP132    =-5;
      YRROP133    =-5;
      YRROP134    =-5;
      YRROP135    =-5;
      YRROP136    =-5;
      BWROP131    =-5;
      BWROP132    =-5;
      BWROP133    =-5;
      BWROP134    =-5;
      PAYRATE13   =-5;
      ROPTU14     =-5;
      SEYROP14    =-5;
      TADAPT14    =-5;
      TYROP14     =-5;
      TCSPAY14    =-5;
      TCSROP14    =-5;
      TCSWKS14    =-5;
      TCSHRW14    =-5;
      TCSNUM14    =-5;
      TPEROP14    =-5;
      THRSWK14    =-5;
      TAPAY141    =-5;
      TAPAY142    =-5;
      TAPAY143    =-5;
      TADWK141    =-5;
      TADWK142    =-5;
      TADWK143    =-5;
      TADHR141    =-5;
      TADHR142    =-5;
      TADHR143    =-5;
      NTMROP14    =-5;
      NTNGAP14    =-5;
      NTSRGD14    =-5;
      NTSRGM14    =-5;
      NTSRGY14    =-5;
      NTERGD14    =-5;
      NTERGM14    =-5;
      NTERGY14    =-5;
      NTSLGD14    =-5;
      NTSLGM14    =-5;
      NTSLGY14    =-5;
      NTELGD14    =-5;
      NTELGM14    =-5;
      NTELGY14    =-5;
      HRROP141    =-5;
      HRROP142    =-5;
      HRROP143    =-5;
      HRROP144    =-5;
      HRROP145    =-5;
      WKROP141    =-5;
      WKROP142    =-5;
      WKROP143    =-5;
      WKROP144    =-5;
      WKROP145    =-5;
      WKROP146    =-5;
      MOROP141    =-5;
      MOROP142    =-5;
      MOROP143    =-5;
      MOROP144    =-5;
      MOROP146    =-5;
      YRROP141    =-5;
      YRROP142    =-5;
      YRROP143    =-5;
      YRROP144    =-5;
      YRROP145    =-5;
      YRROP146    =-5;
      BWROP141    =-5;
      BWROP142    =-5;
      BWROP143    =-5;
      BWROP144    =-5;
      PAYRATE14   =-5;
      UNIONJB1    =-5;
      UNIONJB2    =-5;
      UNIONJB3    =-5;
      UNIONJB4    =-5;
      UNIONJB5    =-5;
      UNIONJB6    =-5;
      UNIONJB7    =-5;
      UNIONJB8    =-5;
      UNIONJB9    =-5;
      UNIONJB10   =-5;
      UNIONJB11   =-5;
      UNIONJB12   =-5;
      UNIONJB13   =-5;
      UNIONJB14   =-5;
      TEACH1      =-5;
      TEACH2      =-5;
      TEACH3      =-5;
      TEACH4      =-5;
      TEACH5      =-5;
      TEACH6      =-5;
      TEACH7      =-5;
      TEACH8      =-5;
      TEACH9      =-5;
      TEACH10     =-5;
      TEACH11     =-5;
      TEACH12     =-5;
      TEACH13     =-5;
      TEACH14     =-5;
      TREGSC1     =-5;
      TREGSC2     =-5;
      TREGSC3     =-5;
      TREGSC4     =-5;
      TREGSC5     =-5;
      TREGSC6     =-5;
      TREGSC7     =-5;
      TREGSC8     =-5;
      TREGSC9     =-5;
      TREGSC10    =-5;
      TREGSC11    =-5;
      TREGSC12    =-5;
      TREGSC13    =-5;
      TREGSC14    =-5;
      PREVID1     =-5;
      PREVID2     =-5;
      PREVID3     =-5;
      PREVID4     =-5;
      PREVID5     =-5;
      PREVID6     =-5;
      PREVID7     =-5;
      PREVID8     =-5;
      PREVID9     =-5;
      PREVID10    =-5;
      PREVID11    =-5;
      PREVID12    =-5;
      PREVID13    =-5;
      PREVID14    =-5;
      JOBTYP1     =-5;
      JOBTYP2     =-5;
      JOBTYP3     =-5;
      JOBTYP4     =-5;
      JOBTYP5     =-5;
      JOBTYP6     =-5;
      JOBTYP7     =-5;
      JOBTYP8     =-5;
      JOBTYP9     =-5;
      JOBTYP10    =-5;
      JOBTYP11    =-5;
      JOBTYP12    =-5;
      JOBTYP13    =-5;
      JOBTYP14    =-5;
      milact      =-5;
      omilcode    =-5;
      INT_D       =-5;
      INT_M       =-5;
      INT_Y       =-5;
      LINT_D      =-5;
      LINT_M      =-5;
      LINT_Y      =-5;
      empnum1     =-5;
      empnum2     =-5;
      empnum3     =-5;
      empnum4     =-5;
      empnum5     =-5;
      empnum6     =-5;
      empnum7     =-5;
      empnum8     =-5;
      empnum9     =-5;
      empnum10    =-5;
      empnum11    =-5;
      empnum12    =-5;
      empnum13    =-5;                      
      empnum14    =-5;                      
end;

array empnum  (i)     empnum1-empnum14;
array jobtyp  (i)     jobtyp1-jobtyp14;
array roptu   (i)     roptu1-roptu14;
array crwkemp (i)     crwkemp1-crwkemp14;
array cow     (i)     cow1-cow14;
array payrate  (i)     payrate1-payrate14;
array hrswk    (i)     hrswk1-hrswk14;
array stajoby  (i)     stajoby1-stajoby14;
array stojoby  (i)     stojoby1-stojoby14;
array check    (i)     check1-check14;
do i = 1 to 14;
    if (jobtyp = 3) then roptu = 6;
    if empnum>=1 then do;
        if jobtyp=-4 then jobtyp=-3;
        if roptu=-4 then roptu=-3;
        if payrate=-4 then payrate=-3;
        if crwkemp=-4 then crwkemp=-3;
        if hrswk=-4 then hrswk=-3;
    end;
    if empnum<1 & stajoby>-4 then check=1;
end;
if weight = 0 then do;
    indf01=-5;
    occf01=-5;
    indf02=-5;
    occf02=-5;
    indf03=-5;
    occf03=-5;
    indf04=-5;
    occf04=-5;
    indf05=-5;
    occf05=-5;
    indf06=-5;
    occf06=-5;
    indf07=-5;
    occf07=-5;
    indf08=-5;
    occf08=-5;
    indf09=-5;
    occf09=-5;
    indf10=-5;
    occf10=-5;
    MOROP15=-5;
    BWROP15=-5;
    BWROP16=-5;
    MOROP25=-5;
    BWROP25=-5;
    BWROP26=-5;
    MOROP35=-5;
    BWROP35=-5;
    BWROP36=-5;
    MOROP45=-5;
    BWROP45=-5;
    BWROP46=-5;
    MOROP55=-5;
    BWROP55=-5;
    BWROP56=-5;
    MOROP65=-5;
    BWROP65=-5;
    BWROP66=-5;
    MOROP75=-5;
    BWROP75=-5;
    BWROP76=-5;
    MOROP85=-5;
    BWROP85=-5;
    BWROP86=-5;
    MOROP95=-5;
    BWROP95=-5;
    BWROP96=-5;
    MOROP105=-5;
    BWROP105=-5;
    BWROP106=-5;
end;
else if weight > 0 then do;
    indf01=-4;
    occf01=-4;
    indf02=-4;
    occf02=-4;
    indf03=-4;
    occf03=-4;
    indf04=-4;
    occf04=-4;
    indf05=-4;
    occf05=-4;
    indf06=-4;
    occf06=-4;
    indf07=-4;
    occf07=-4;
    indf08=-4;
    occf08=-4;
    indf09=-4;
    occf09=-4;
    indf10=-4;
    occf10=-4;
    MOROP15=-4;
    BWROP15=-4;
    BWROP16=-4;
    MOROP25=-4;
    BWROP25=-4;
    BWROP26=-4;
    MOROP35=-4;
    BWROP35=-4;
    BWROP36=-4;
    MOROP45=-4;
    BWROP45=-4;
    BWROP46=-4;
    MOROP55=-4;
    BWROP55=-4;
    BWROP56=-4;
    MOROP65=-4;
    BWROP65=-4;
    BWROP66=-4;
    MOROP75=-4;
    BWROP75=-4;
    BWROP76=-4;
    MOROP85=-4;
    BWROP85=-4;
    BWROP86=-4;
    MOROP95=-4;
    BWROP95=-4;
    BWROP96=-4;
    MOROP105=-4;
    BWROP105=-4;
    BWROP106=-4;
end;

R30_IANDO_MERGEFINAL.SAS

Variable Names in program      Variable Names in data release
emp_ind_01   =                 'EMPLOYER_IND.01'n         ;
emp_ind_02   =                 'EMPLOYER_IND.02'n         ;
emp_ind_03   =                 'EMPLOYER_IND.03'n         ;
emp_ind_04   =                 'EMPLOYER_IND.04'n         ;
emp_ind_05   =                 'EMPLOYER_IND.05'n         ;
emp_ind_06   =                 'EMPLOYER_IND.06'n         ;
emp_ind_07   =                 'EMPLOYER_IND.07'n         ;
empnam1      =                 'EMPLOYER_NAME.01'n        ;
empnam2      =                 'EMPLOYER_NAME.02'n        ;
empnam3      =                 'EMPLOYER_NAME.03'n        ;
empnam4      =                 'EMPLOYER_NAME.04'n        ;
empnam5      =                 'EMPLOYER_NAME.05'n        ;
empnam6      =                 'EMPLOYER_NAME.06'n        ;
empnam7      =                 'EMPLOYER_NAME.07'n        ;
empnam8      =                 'EMPLOYER_NAME.08'n        ;
empnam9      =                 'EMPLOYER_NAME.09'n        ;
empnam10      =                'EMPLOYER_NAME.10'n        ;
empnam11      =                'EMPLOYER_NAME.11'n        ;
empnam12      =                'EMPLOYER_NAME.12'n        ;
empnam13      =                'EMPLOYER_NAME.13'n        ;
empnam14      =                'EMPLOYER_NAME.14'n        ;
emp_occ1_01  =                 'EMPLOYER_OCC1.01'n        ;
emp_occ1_02  =                 'EMPLOYER_OCC1.02'n        ;
emp_occ1_03  =                 'EMPLOYER_OCC1.03'n        ;
emp_occ1_04  =                 'EMPLOYER_OCC1.04'n        ;
emp_occ1_05  =                 'EMPLOYER_OCC1.05'n        ;
emp_occ1_06  =                 'EMPLOYER_OCC1.06'n        ;
emp_occ1_07  =                 'EMPLOYER_OCC1.07'n        ;
emp_occ2_01  =                 'EMPLOYER_OCC2.01'n        ;
emp_occ2_02  =                 'EMPLOYER_OCC2.02'n        ;
emp_occ2_03  =                 'EMPLOYER_OCC2.03'n        ;
emp_occ2_04  =                 'EMPLOYER_OCC2.04'n        ;
emp_occ2_05  =                 'EMPLOYER_OCC2.05'n        ;
emp_occ2_06  =                 'EMPLOYER_OCC2.06'n        ;
emp_occ2_07  =                 'EMPLOYER_OCC2.07'n        ;
emp_uid_01   =                 'EMPLOYER_UID.01'n         ;
emp_uid_02   =                 'EMPLOYER_UID.02'n         ;
emp_uid_03   =                 'EMPLOYER_UID.03'n         ;
emp_uid_04   =                 'EMPLOYER_UID.04'n         ;
emp_uid_05   =                 'EMPLOYER_UID.05'n         ;
emp_uid_06   =                 'EMPLOYER_UID.06'n         ;
emp_uid_07   =                 'EMPLOYER_UID.07'n         ;
emp_uid_08   =                 'EMPLOYER_UID.08'n         ;
emp_uid_09   =                 'EMPLOYER_UID.09'n         ;
emp_uid_10   =                 'EMPLOYER_UID.10'n         ;
emp_uid_11   =                 'EMPLOYER_UID.11'n         ;
emp_uid_12   =                 'EMPLOYER_UID.12'n         ;
emp_uid_13   =                 'EMPLOYER_UID.13'n         ;
emp_uid_14   =                 'EMPLOYER_UID.14'n         ;
spoccchg1    =                 'OCCSP-55C'n                 ;
spoccchg2    =                 'OCCSP-55DA'n                ;
occspr30     =                 'OCCSP-55H'n                 ;
occspr30_2   =                 'OCCSP-55H_1'n               ;
spocc1       =                 'OCCSP-55I'n                 ;
spocc2       =                 'OCCSP-55J'n                 ;
cps_hrs_chk1 =                 'QES-53A.01'n              ;
cps_hrs_chk2 =                 'QES-53A.02'n              ;
cps_hrs_chk3 =                 'QES-53A.03'n              ;
cps_hrs_chk4 =                 'QES-53A.04'n              ;
cps_hrs_chk5 =                 'QES-53A.05'n              ;
cps_hrs_chk6 =                 'QES-53A.06'n              ;
cps_hrs_chk7 =                 'QES-53A.07'n              ;
cps_hrs_chk8 =                 'QES-53A.08'n              ;
cps_hrs_chk9 =                 'QES-53A.09'n              ;
cps_hrs_chk10 =                'QES-53A.10'n              ;
cps_hrs_chk11 =                'QES-53A.11'n              ;
cps_hrs_chk12 =                'QES-53A.12'n              ;
cps_hrs_chk13 =                'QES-53A.13'n              ;
cps_hrs_chk14 =                'QES-53A.14'n              ;
cps_wks_chk1 =                 'QES-54B.01'n              ;
cps_wks_chk2 =                 'QES-54B.02'n              ;
cps_wks_chk3 =                 'QES-54B.03'n              ;
cps_wks_chk4 =                 'QES-54B.04'n              ;
cps_wks_chk5 =                 'QES-54B.05'n              ;
cps_wks_chk6 =                 'QES-54B.06'n              ;
cps_wks_chk7 =                 'QES-54B.07'n              ;
cps_wks_chk8 =                 'QES-54B.08'n              ;
cps_wks_chk9 =                 'QES-54B.09'n              ;
cps_wks_chk10=                 'QES-54B.10'n              ;
cps_wks_chk11=                 'QES-54B.11'n              ;
cps_wks_chk12=                 'QES-54B.12'n              ;
cps_wks_chk13=                 'QES-54B.13'n              ;
cps_wks_chk14=                 'QES-54B.14'n              ;
ind1         =                 'QES-55E.01'n              ;
ind2         =                 'QES-55E.02'n              ;
ind3         =                 'QES-55E.03'n              ;
ind4         =                 'QES-55E.04'n              ;
ind5         =                 'QES-55E.05'n              ;
ind6         =                 'QES-55E.06'n              ;
ind7         =                 'QES-55E.07'n              ;
ind8         =                 'QES-55E.08'n              ;
ind9         =                 'QES-55E.09'n              ;
ind10         =                'QES-55E.10'n              ;
ind11         =                'QES-55E.11'n              ;
ind14         =                'QES-55E.14'n              ;
occ11        =                 'QES-55H.01'n              ;
occ12        =                 'QES-55H.02'n              ;
occ13        =                 'QES-55H.03'n              ;
occ14        =                 'QES-55H.04'n              ;
occ15        =                 'QES-55H.05'n              ;
occ16        =                 'QES-55H.06'n              ;
occ17        =                 'QES-55H.07'n              ;
occ18        =                 'QES-55H.08'n              ;
occ19        =                 'QES-55H.09'n              ;
occ110       =                 'QES-55H.10'n              ;
occ111       =                 'QES-55H.11'n              ;
occ114       =                 'QES-55H.14'n              ;
occ21        =                 'QES-55J.01'n              ;
occ22        =                 'QES-55J.02'n              ;
occ23        =                 'QES-55J.03'n              ;
occ24        =                 'QES-55J.04'n              ;
occ25        =                 'QES-55J.05'n              ;
occ26        =                 'QES-55J.06'n              ;
occ27        =                 'QES-55J.07'n              ;
occ28        =                 'QES-55J.08'n              ;
occ29        =                 'QES-55J.09'n              ;
occ210       =                 'QES-55J.10'n              ;
occ211       =                 'QES-55J.11'n              ;
occ214       =                 'QES-55J.14'n              ;
spoc1dli     =                 'SYMBOL_SPAR_OCC1DLI'n     ;
spoc2dli     =                 'SYMBOL_SPAR_OCC2DLI'n     ;
totemp2      =                 'SYMBOL_TOTEMP'n           ;
samesp       =                 'OCCSP-0A'n           ;
newsp        =                 'OCCSP-0B'n           ;
newsp        =                 'OCCSP-0B'n           ;
div_wid      =                 'Q2-11'n           ;

r30_flag=1;
totemp = 0;
if (totemp2 > -4) then totemp = totemp2;
jobtyp1=0;
if (ind1 ~= ' ' or occ11 ~= ' ' or occ21 ~= ' ') then jobtyp1=1;
jobtyp2=0;
if (ind2 ~= ' ' or occ12 ~= ' ' or occ22 ~= ' ') then jobtyp2=2;
jobtyp3=0;
if (ind3 ~= ' ' or occ13 ~= ' ' or occ23 ~= ' ') then jobtyp3=3;
jobtyp4=0;
if (ind4 ~= ' ' or occ14 ~= ' ' or occ24 ~= ' ') then jobtyp4=4;
jobtyp5=0;
if (ind5 ~= ' ' or occ15 ~= ' ' or occ25 ~= ' ') then jobtyp5=5;
jobtyp6=0;
if (ind6 ~= ' ' or occ16 ~= ' ' or occ26 ~= ' ') then jobtyp6=6;
jobtyp7=0;
if (ind7 ~= ' ' or occ17 ~= ' ' or occ27 ~= ' ') then jobtyp7=7;
jobtyp8=0;
if (ind8 ~= ' ' or occ18 ~= ' ' or occ28 ~= ' ') then jobtyp8=8;
jobtyp9=0;
if (ind9 ~= ' ' or occ19 ~= ' ' or occ29 ~= ' ') then jobtyp9=9;
jobtyp10=0;
if (ind10 ~= ' ' or occ110 ~= ' ' or occ210 ~= ' ') then jobtyp10=10;
jobtyp11=0;
if (ind11 ~= ' ' or occ111 ~= ' ' or occ211 ~= ' ') then jobtyp11=11;
jobtyp14=0;
if (ind14 ~= ' ' or occ114 ~= ' ' or occ214 ~= ' ') then jobtyp14=14;
jobtyps=0;
if (spocc1 ~= ' ' or spocc2 ~= ' ') then jobtyps=21;

jbtyp1a=0;
if (ind1 = ' ' & occ11 = ' ' & occ21 = ' ' & empnam1 ~= ' '
   & empnam1 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp1a=1;
jbtyp2a=0;
if (ind2 = ' ' & occ12 = ' ' & occ22 = ' ' & empnam2 ~= ' '
   & empnam2 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp2a=2;
jbtyp3a=0;
if (ind3 = ' ' & occ13 = ' ' & occ23 = ' ' & empnam3 ~= ' '
   & empnam3 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp3a=3;
jbtyp4a=0;
if (ind4 = ' ' & occ14 = ' ' & occ24 = ' ' & empnam4 ~= ' '
   & empnam4 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp4a=4;
jbtyp5a=0;
if (ind5 = ' ' & occ15 = ' ' & occ25 = ' ' & empnam5 ~= ' '
   & empnam5 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp5a=5;
jbtyp6a=0;
if (ind6 = ' ' & occ16 = ' ' & occ26 = ' ' & empnam6 ~= ' '
   & empnam6 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp6a=6;
jbtyp7a=0;
if (ind7 = ' ' & occ17 = ' ' & occ27 = ' ' & empnam7 ~= ' '
   & empnam7 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp7a=7;
jbtyp8a=0;
if (ind8 = ' ' & occ18 = ' ' & occ28 = ' ' & empnam8 ~= ' '
   & empnam8 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp8a=8;
jbtyp9a=0;
if (ind9 = ' ' & occ19 = ' ' & occ29 = ' ' & empnam9 ~= ' '
   & empnam9 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp9a=9;
jbtyp10a=0;
if (ind10 = ' ' & occ110 = ' ' & occ210 = ' ' & empnam10 ~= ' '
   & empnam10 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp10a=10;
jbtyp11a=0;
if (ind11 = ' ' & occ111 = ' ' & occ211 = ' ' & empnam11 ~= ' '
   & empnam11 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp11a=11;
jbtyp14a=0;
if (ind14 = ' ' & occ114 = ' ' & occ214 = ' ' & empnam14 ~= ' '
   & empnam14 ~= 'NO EMPLOYER MATCH' & totemp > 0) then jbtyp14a=14;
jbtypsa1=0;
if (spocc1 = ' ' & spocc2 = ' ' & (spoccchg1 = 1 | spoccchg2 = 1)) then jbtypsa1=21;
jbtypsa2=0;
if (spocc1 = ' ' & spocc2 = ' ' & (occspr30 = -4 | occspr30 = 2 | occspr30 = 3)) then jbtypsa2=22;
array    indd    (i) $    ind1-ind14;
array    indc    (i)        ind_code_c1-ind_code_c14;
array    occd1    (i)    $    occ11-occ19 occ110-occ114;
array    occd2    (i)    $    occ21-occ29 occ210-occ214;
array    occc    (i)        occ_code_c1-occ_code_c14;
do i=1 to 14;
    if indd~=' ' & indc=. then indc=-3;
    if (occd1~=' ' or occd2~=' ') & occc=. then occc=-3;
end;

array     emp_uid     (i)    emp_uid_01-emp_uid_14;
array     check     (i)    check_01-check_14;
do i=1 to 14;
    if emp_uid>0 & (indc=-3|occc=-3) then check=1;
    else if emp_uid>0 & (indc=.|occc=.) then check=2;
    else if emp_uid=. & (indc>=-3|occc>=-3) then check=3;
end;
rename
 R0000100 = pubid        
 R0000110 = norcid       
 R6552700 = previd20001  
 R6552800 = previd20002  
 R6552900 = previd20003  
 R6553000 = previd20004  
 R6553100 = previd20005  
 R6963402 = lintyr2000   
 R7178900 = previd20021  
 R7179000 = previd20022  
 R7179100 = previd20023  
 R7179200 = previd20024  
 R7179300 = previd20025  
 R7656402 = lintyr2002   
 R7864600 = previd20041  
 R7864700 = previd20042  
 R7864800 = previd20043  
 R7864900 = previd20044  
 R7865000 = previd20045  
 R8423302 = lintyr2004   
 T0107100 = previd20061  
 T0107200 = previd20062  
 T0107300 = previd20063  
 T0107400 = previd20064  
 T0107500 = previd20065  
 T0967402 = lintyr2006   
 T2190602 = lintyr2008   
 T2226100 = previd20081  
 T2226200 = previd20082  
 T2226300 = previd20083  
 T2226400 = previd20084  
 T2226500 = previd20085  
 T2226600 = previd20086  
 T2226700 = previd20087  
 T2226800 = previd20088  
 T2226900 = previd20089  
 T2227000 = previd200810 
 T2227100 = previd200811 
 T3101802 = lintyr2010   
 T3187000 = previd20101  
 T3187100 = previd20102  
 T3187200 = previd20103  
 T3187300 = previd20104  
 T3187400 = previd20105  
 T3187500 = previd20106  
 T3187600 = previd20107  
 T3187700 = previd20108  
 T3187800 = previd20109  
 T3187900 = previd201010 
 T4127300 = previd20121  
 T4127400 = previd20122  
 T4127500 = previd20123  
 T4127600 = previd20124  
 T4127700 = previd20125  
 T4127800 = previd20126  
 T4127900 = previd20127  
 T4128000 = previd20128  
 T4128100 = previd20129  
 T4160502 = lintyr2012   
 T5014702 = lintyr2014   
 T5053900 = previd20141  
 T5054000 = previd20142  
 T5054100 = previd20143  
 T5054200 = previd20144  
 T5054300 = previd20145  
 T5054400 = previd20146  
 T5054500 = previd20147  
 T5790702 = lintyr2016  
 T5805600 = previd20161 
 T5805700 = previd20162 
 T5805800 = previd20163 
 T5805900 = previd20164 
 T5806000 = previd20165 
 T5806100 = previd20166 
 T5806200 = previd20167 
 T5806300 = previd20168 
 T8240402 = lintyr2018  
 T8260200 = previd20181 
 T8260300 = previd20182 
 T8260400 = previd20183 
 T8260500 = previd20184 
 T8260600 = previd20185 
 T8260700 = previd20186 
 T8260800 = previd20187 
 T8260900 = previd20188 
 T8261000 = previd20189  
 T8809302 = lintyr2020        
 T8828200 = previd20201      
 T8828300 = previd20202      
 T8828400 = previd20203      
 T8828500 = previd20204      
 T8828600 = previd20205      
 T8828700 = previd20206      
 T8828800 = previd202013      
 T9322902 = lintyr2022          
 T9355400 = previd20221    
 T9355500 = previd20222    
 T9355600 = previd20223    
 T9355700 = previd20224    
 T9355800 = previd20225    
 T9355900 = previd20226    
 T9356000 = previd20227    
 T9356100 = previd20228
 T9356200 = previd202214    
;
 pubid      /*'CASEID_1979'n*/
 norcid     /*'NORCID_1979'n*/
 ind20001   /*'INDALL-EMP.01_2000'n*/
 ind20002   /*'INDALL-EMP.02_2000'n*/
 ind20003   /*'INDALL-EMP.03_2000'n*/
 ind20004   /*'INDALL-EMP.04_2000'n*/
 ind20005   /*'INDALL-EMP.05_2000'n*/
 occ20001   /*'OCCALL-EMP.01_2000'n*/
 occ20002   /*'OCCALL-EMP.02_2000'n*/
 occ20003   /*'OCCALL-EMP.03_2000'n*/
 occ20004   /*'OCCALL-EMP.04_2000'n*/
 occ20005   /*'OCCALL-EMP.05_2000'n*/
 spocc2000   /*'OCCSP-55I_CODE_2000'n*/
 ind20021   /*'INDALL-EMP.01_2002'n*/
 ind20022   /*'INDALL-EMP.02_2002'n*/
 ind20023   /*'INDALL-EMP.03_2002'n*/
 ind20024   /*'INDALL-EMP.04_2002'n*/
 ind20025   /*'INDALL-EMP.05_2002'n*/
 occ20021   /*'OCCALL-EMP.01_2002'n*/
 occ20022   /*'OCCALL-EMP.02_2002'n*/
 occ20023   /*'OCCALL-EMP.03_2002'n*/
 occ20024   /*'OCCALL-EMP.04_2002'n*/
 occ20025   /*'OCCALL-EMP.05_2002'n*/
 spocc2002   /*'OCCSP-55I_CODE_2002'n*/
 ind20041   /*'INDALL-EMP.01_2004'n*/
 ind20042   /*'INDALL-EMP.02_2004'n*/
 ind20043   /*'INDALL-EMP.03_2004'n*/
 ind20044   /*'INDALL-EMP.04_2004'n*/
 ind20045   /*'INDALL-EMP.05_2004'n*/
 occ20041   /*'OCCALL-EMP.01_2004'n*/
 occ20042   /*'OCCALL-EMP.02_2004'n*/
 occ20043   /*'OCCALL-EMP.03_2004'n*/
 occ20044   /*'OCCALL-EMP.04_2004'n*/
 occ20045   /*'OCCALL-EMP.05_2004'n*/
 spocc2004   /*'OCCSP-55I_CODE_2004'n*/
 ind20061   /*'INDALL-EMP.01_2006'n*/
 ind20062   /*'INDALL-EMP.02_2006'n*/
 ind20063   /*'INDALL-EMP.03_2006'n*/
 ind20064   /*'INDALL-EMP.04_2006'n*/
 ind20065   /*'INDALL-EMP.05_2006'n*/
 occ20061   /*'OCCALL-EMP.01_2006'n*/
 occ20062   /*'OCCALL-EMP.02_2006'n*/
 occ20063   /*'OCCALL-EMP.03_2006'n*/
 occ20064   /*'OCCALL-EMP.04_2006'n*/
 occ20065   /*'OCCALL-EMP.05_2006'n*/
 spocc2006   /*'OCCSP-55I_CODE_2006'n*/
 ind20081   /*'INDALL-EMP.01_2008'n*/
 ind20082   /*'INDALL-EMP.02_2008'n*/
 ind20083   /*'INDALL-EMP.03_2008'n*/
 ind20084   /*'INDALL-EMP.04_2008'n*/
 ind20085   /*'INDALL-EMP.05_2008'n*/
 occ20081   /*'OCCALL-EMP.01_2008'n*/
 occ20082   /*'OCCALL-EMP.02_2008'n*/
 occ20083   /*'OCCALL-EMP.03_2008'n*/
 occ20084   /*'OCCALL-EMP.04_2008'n*/
 occ20085   /*'OCCALL-EMP.05_2008'n*/
 spocc2008   /*'OCCSP-55I_CODE_2008'n*/
 ind20101   /*'INDALL-EMP.01_2010'n*/
 ind20102   /*'INDALL-EMP.02_2010'n*/
 ind20103   /*'INDALL-EMP.03_2010'n*/
 ind20104   /*'INDALL-EMP.04_2010'n*/
 ind20105   /*'INDALL-EMP.05_2010'n*/
 occ20101   /*'OCCALL-EMP.01_2010'n*/
 occ20102   /*'OCCALL-EMP.02_2010'n*/
 occ20103   /*'OCCALL-EMP.03_2010'n*/
 occ20104   /*'OCCALL-EMP.04_2010'n*/
 occ20105   /*'OCCALL-EMP.05_2010'n*/
 spocc2010   /*'OCCSP-55I_CODE_2010'n*/
 ind20121   /*'INDALL-EMP.01_2012'n*/
 ind20122   /*'INDALL-EMP.02_2012'n*/
 ind20123   /*'INDALL-EMP.03_2012'n*/
 ind20124   /*'INDALL-EMP.04_2012'n*/
 ind20125   /*'INDALL-EMP.05_2012'n*/
 occ20121   /*'OCCALL-EMP.01_2012'n*/
 occ20122   /*'OCCALL-EMP.02_2012'n*/
 occ20123   /*'OCCALL-EMP.03_2012'n*/
 occ20124   /*'OCCALL-EMP.04_2012'n*/
 occ20125   /*'OCCALL-EMP.05_2012'n*/
 spocc2012   /*'OCCSP-55I_CODE_2012'n*/

lastint2022=0;
if (lintyr2020 > -4) then lastint2022=2020;
else if (lintyr2018 > -4) then lastint2022=2018;
else if (lintyr2016 > -4) then lastint2022=2016;
else if (lintyr2014 > -4) then lastint2022=2014;
else if (lintyr2012 > -4) then lastint2022=2012;
else if (lintyr2010 > -4) then lastint2022=2010;
else if (lintyr2008 > -4) then lastint2022=2008;
else if (lintyr2006 > -4) then lastint2022=2006;
else if (lintyr2004 > -4) then lastint2022=2004;
else if (lintyr2002 > -4) then lastint2022=2002;
else if (lintyr2000 > -4) then lastint2022=2000;
%macro att(yrb);
%do l=1 %to 14;
    %do a=1 %to 10;
        if ind_code_c&l > 0 & ind_code_c&l~=9990 then indf2022&l = ind_code_c&l;
        else if lastint2022=&yrb & previd2022&l=&a & ind&yrb&a>=-3 then indf2022&l=ind&yrb&a;
        else if indf2022&l =. & ind_code_c&l=9990 then indf2022&l =ind_code_c&l;
        if occ_code_c&l > 0 & occ_code_c&l~=9990 then occf2022&l = occ_code_c&l;
        else if lastint2022=&yrb & previd2022&l=&a & occ&yrb&a>=-3 then occf2022&l=occ&yrb&a;
        else if occf2022&l =. & occ_code_c&l=9990 then occf2022&l = occ_code_c&l;
    %end;
%end;
%mend att;
%macro rd;
   %do yrb = 2020 %to 2002 %by -2;
       %att(&yrb);
   %end; 
%mend rd;
%rd;
if ind_code_c1=. & lastint2022=2002 & previd20221>0 & indf20221>0 then indf20221=indf20221*10;
if ind_code_c2=. & lastint2022=2002 & previd20222>0 & indf20222>0 then indf20222=indf20222*10;
if ind_code_c3=. & lastint2022=2002 & previd20223>0 & indf20223>0 then indf20223=indf20223*10;
if ind_code_c4=. & lastint2022=2002 & previd20224>0 & indf20224>0 then indf20224=indf20224*10;
if ind_code_c5=. & lastint2022=2002 & previd20225>0 & indf20225>0 then indf20225=indf20225*10;
if ind_code_c6=. & lastint2022=2002 & previd20226>0 & indf20226>0 then indf20226=indf20226*10;
if ind_code_c7=. & lastint2022=2002 & previd20227>0 & indf20227>0 then indf20227=indf20227*10;
if ind_code_c8=. & lastint2022=2002 & previd20228>0 & indf20228>0 then indf20228=indf20228*10;
if ind_code_c9=. & lastint2022=2002 & previd20229>0 & indf20229>0 then indf20229=indf20229*10;
if ind_code_c10=. & lastint2022=2002 & previd202210>0 & indf202210>0 then indf202210=indf202210*10;
if ind_code_c11=. & lastint2022=2002 & previd202211>0 & indf202211>0 then indf202211=indf202211*10;
if ind_code_c12=. & lastint2022=2002 & previd202212>0 & indf202212>0 then indf202212=indf202212*10;
if ind_code_c13=. & lastint2022=2002 & previd202213>0 & indf202213>0 then indf202213=indf202213*10;
if ind_code_c14=. & lastint2022=2002 & previd202214>0 & indf202214>0 then indf202214=indf202214*10;
if occ_code_c1=. & lastint2022=2002 & previd20221>0 & occf20221>0 then occf20221=occf20221*10;
if occ_code_c2=. & lastint2022=2002 & previd20222>0 & occf20222>0 then occf20222=occf20222*10;
if occ_code_c3=. & lastint2022=2002 & previd20223>0 & occf20223>0 then occf20223=occf20223*10;
if occ_code_c4=. & lastint2022=2002 & previd20224>0 & occf20224>0 then occf20224=occf20224*10;
if occ_code_c5=. & lastint2022=2002 & previd20225>0 & occf20225>0 then occf20225=occf20225*10;
if occ_code_c6=. & lastint2022=2002 & previd20226>0 & occf20226>0 then occf20226=occf20226*10;
if occ_code_c7=. & lastint2022=2002 & previd20227>0 & occf20227>0 then occf20227=occf20227*10;
if occ_code_c8=. & lastint2022=2002 & previd20228>0 & occf20228>0 then occf20228=occf20228*10;
if occ_code_c9=. & lastint2022=2002 & previd20229>0 & occf20229>0 then occf20229=occf20229*10;
if occ_code_c10=. & lastint2022=2002 & previd202210>0 & occf202210>0 then occf202210=occf202210*10;
if occ_code_c11=. & lastint2022=2002 & previd202211>0 & occf202211>0 then occf202211=occf202211*10;
if occ_code_c12=. & lastint2022=2002 & previd202212>0 & occf202212>0 then occf202212=occf202212*10;
if occ_code_c13=. & lastint2022=2002 & previd202213>0 & occf202213>0 then occf202213=occf202213*10;
if occ_code_c14=. & lastint2022=2002 & previd202214>0 & occf202214>0 then occf202214=occf202214*10;

Users should be aware that not all of the variables listed in the programs above appear in the NLSY79 public release data file. Variables with no valid data for any respondent, jobs 6-10, within-job gap 4, and between-job gaps 5-6 are not currently included in the main file.

End notes

[Note 1] All week number references in this program are relative to 1/1/78 and end with the most recent interview date. A week #0 is included at the beginning of the week-by-week array structures to indicate time prior to 1/1/78. Users are discouraged from incorporating data contained in this week in analysis. Researchers should instead use information from the 1979 interview concerning labor force activity prior to 1/1/78 in order to construct event histories of a more thorough nature. (Some information concerning labor force activity for respondents prior to the time frame of the initial 1979 interview is asked on an age restricted basis for respondents still in their teens at the time of interview.)

[Note 2] All variables have standard missing value codes unless otherwise noted.

[Note 3] The final 2022 (round 30) interviews were conducted in September 2023. Therefore, valid data are only present through variables for week #2384 in the current data set. The maximum week number variable in the Dual Job [#] arrays is week #2348, as no one reported multiple jobs in weeks #2249-2384.