Skip to main content

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 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.

NLSY79 Appendix 17: Interviewer Characteristics Data

Interviewer characteristics data and data review

Many researchers are interested in knowing if or how much interviewers affect respondents' answers. To enable researchers to investigate these questions, NLSY79 data releases since 1988 have contained information on interviewers' characteristics.

Constructing the Interviewer Characteristics ID and Interview Attribute variables

The key variable, which links the NLSY data set with the interviewer characteristics data set, is INTCHARS_INT_ID. This ID variable is often similar but not necessarily identical to the Interviewer ID variable, which is entered in the questionnaire and can be found on the NLSY79 public use data set for many years. INTCHARS_INT_ID is a constructed longitudinal variable that allows identification of cases interviewed by the same person over time. While some interviewers were assigned multiple IDs during their tenure, it was possible to successfully connect the records of most interviewers through their active years.

Each round, new IDs are assigned to new interviewers who do not have a longitudinal ID. From 1979-2000, information on the characteristics of NLSY79 interviewers primarily comes from NORC's interviewer personnel files. Data from the 2002-present surveys come from forms filled in by interviewers during their NLSY79 training program. Collecting this information directly from interviewers before each round ensures that the interviewer characteristics data is up to date at the start of data collection. Users should note that not all interviewers have filled out this demographic survey in the survey years that they worked. 

The variables that document Interviewer-specific traits are found in the “Interviewer Characteristics” Area of Interest:

  • INTCHARS_YRSINTR: Interviewer Count (available 1979 - 2014)
    • This counts the number of years the interviewer has interviewed the respondent, including the current survey year. Note that as telephone interviews become more prevalent, the number of first-time interviews expands considerably, as most interviewers are not assigned to specific cases year after year.
  • INTCHARS_RACE: Interviewer Race (available all years)
    • 1 = WHITE
    • 2 = BLACK
    • 3 = HISPANIC
    • 4 = ASIAN
    • 5 = AMERICAN INDIAN
    • 6 = MULTICULTURAL (available beginning in 2016)
    • 7 = OTHER (available beginning in 2018)
    • -3 = missing
  • INTCHARS_SEX: Interviewer Sex (available all years)
    • 1 = MALE
    • 2 = FEMALE
    • -3 = missing
  • INTCHARS_AGE: Interviewer Age (available 1979-2014)
    • Age of the interviewer in the interview year, calculated as ([survey year]-[interviewer’s year of birth])
    • -3 = missing
  • INTCHARS_EDUCATION: Interviewer Education (available all years)
    • 1 = Grade 0-8
    • 2 = Grade 9-11
    • 3 = High School Graduate
    • 4 = Vocational degree
    • 5 = Some College
    • 6 = College Graduate
    • 7 = Graduate School
    • 8 = Masters Degree
    • 9 = Professional Degree
    • 0 = Other
  • INTCHARS_FI_EXP: Interviewer Experience (available 2016-current round)
    • Interviewer experience in years, from < 1 – 17+ years
    • -3 = missing
  • INTCHARS_HISPANIC: Interviewer of Hispanic Ethnicity (available 2016-current round)
    • 0 = Non-Hispanic
    • 1 = Hispanic
    • -3 = missing
  • INTCHARS_DEM: Interviewer Demographic Data Released (available 2018-current round)
    • Indicates if the interviewer provided permission to release demographic data.
    • 1 = Yes
    • 0 = No
  • INTCHARS_HPC: Hours Per Case (available 2018-current round)
    • Interviewer average hours per case as percentage of project hours per case in the first 8 weeks of fielding.
    • -3 = missing
  • INTCHARS_POS: Interviewer Position (available 2018-current round)
    • 1 = Field Interviewer
    • 2 = Field Manager
  • INTCHARS_SPANISH_SPEAK: Interviewer Position (available 2018-current round)
    • 1 = Yes
    • 2 = No
  • INTCHARS_OCC: Interviewer Occupation (available 2018-current round)
    Open-ended response that asks interviewers to describe their previous or other current occupation(s) besides interviewing. These responses are coded in the following occupation categories:
    • 0 = Not employed
    • 1 = Interviewer
    • 2 = Teaching
    • 3 = Sales and customer service
    • 4 = Administrative assistant, secretarial, clerical & accounts
    • 5 = Medical/health care administrator
    • 6 = Nursing, social work, mental health practitioner, pharmacists & medical    assistants
    • 7 = Insurance, real estate & travel agent
    • 8 = Small business owner
    • 9 = Self-employed & other occupations
    • 10 = Other (professional)
    • 11 = Manager, Supervisor, Director
    • 12 = Social worker, Counselor, Non-profit
    • 13 = Government

Other variables found in the “Survey Methodology” Area of Interest document the interviewers time with the project.

  • R##_FI_START~[M/Y]: Interviewer Start Date (available 2018-current round)
    Month/year interviewer started working on current NLSY79 round.
  • R##_FI_END~[M/Y]: Interviewer End Date (available 2018-current round)
    Date Interviewer stopped working on current NLSY79 round.
  • R##_FI_FIRST_DAY: Interviewer First Work Day (available 2018- current round)
    First day of field period that interviewer worked on current NLSY79 round.
  • R##_FI_LAST_DAY: Interviewer Last Work Day (available 2018- current round)
    Last day of field period that interviewer worked on current NLSY79 round.

Constructing the Interview Characteristics variables

Variables that summarize interactions with respondents, survey characteristics, and field activities are found in the “Survey Methodology” Area of Interest.

A portion of interviews each survey round are reviewed by a human coder to evaluate interview quality as part of the NLSY computer audio recorded interview (CARI) monitoring process and select variables summarize the review. During the CARI process, portions of recorded interviews are reviewed for data quality to provide feedback to the interviewer. The audio review outcome variable provides the results of these reviews at an individual case level. Note that not all cases are reviewed, so many interviews will not have an audio review outcome.

  • R##_REVIEW_OUTCOME: Audio Review Outcome (available 2016-current round)
    Results of review of audio recordings for this interview for data quality assurance.
    • 1 = High quality
    • 2 = Case had minor quality issues
    • 3 = Not reviewed

Interviewers are also categorized into quality tiers based on the aggregate results of all CARI reviews of their cases. The FI quality tier variable records this information, where cases are linked to interviewers using the process described above for interviewer characteristics variables. 

  • R##_FI_QUALITY_TIER: FI Quality Tier (available 2016-current round)
    Indicates the final quality assessment of the field interviewer completing the interview, not necessarily quality of the specific interview.
    • 1 = Confirmed High Quality
    • 2 = Partially Confirmed High Quality
    • 3 = Some Issues, Quality Acceptable
    • 4 = Significant Issues

Variables for locating, case disposition, attempts, outreach, and case refusals are constructed from NORC’s case management system that records all contacts with a case. Starting in 2018, an outreach attempts variable was also included to distinguish between all effort spent on a case and outreach that represented a direct attempt to contact a case. These outreach attempts are a subset of the total attempts variable.

  • R##_LOCATING: Case to Locating (available 2016-current round)
    Indicates if the case was every assigned to locating during the data collection round.
    • 0 = Not assigned to locating
    • 1 = Assigned to locating
  • R##_DISP_DATE: Disposition Date (available 2016-current round)
    Date case disposition assigned.
  • R##_FIRST_ATTEMPT: Field Day 1st Attempt (available 2016-current round)
    Sequential day of the field period when first contact was made with case.
  • R##_LAST_ATTEMPT: Field Day Last Attempt (available 2016-current round)
    Sequential day of the field period when last attempt at contact with case was made.
  • R##_PEOPLE_WORKING: People Working (available 2018- current round)
    Total number of interviewers that worked on the case.
  • R##_OUTREACH_ATTEMPTS: Interviewer Outreach Attempts (available 2018- current round)
    The number of times a project staff member attempted to reach the case. This number includes only attempts to reach the case and other individuals who might be helpful in completing the interview (including locating for outreach) and omits comments and case review notes by interviewers.
  • R##_IN_PERSON_OUTREACH: In-Person Outreach (available 2016-current round)
    • 0 = No in-person outreach made
    • 1 = In-person outreach made
  • R##_REFUSED: R Ever Refused Interview (available 2016-current round)
    Indicates if the case ever refused to participate during various contact attempts in the round. Interview may eventually have been completed.
    • 1 = R refused at least once to participate in interview
    • 0 = R never refused to participate in interview
  • R##_ATTEMPTS: Number of Total Attempts Across Round (available 2018-current round)
    Number of times project staff tried to contact case (all types of contact)
  • R##_ATTEMPTS_EB: Interviewer Attempts Early Bird (available 2016-current round)
    Number of contact attempts during Early Bird phase (first 4 weeks after case released for interview).
  • R##_ATTEMPTS_OUTBOUND: Interviewer Attempts Outbound (available 2016-2020)
    Number of contact attempts after Early Bird phase, during outbound dialing phase.
  • R##_ATTEMPTS_CASE_MANAGED: Interviewer Attempts Case Managed (available 2016-current round)
    Number of contact attempts during case-managed phase of field period, after outbound dialing phase.
  • R##_EB_COMPLETE: EB Complete (available 2016 only)
    • 1 = Yes
    • 0 = No

A replicate group variable is included starting in 2016, which is assigned based on the likelihood that a case will complete that round. The definitions of these groups can vary by round, but in all rounds are constructed based on the likelihood that a respondent will complete, which is then used in targeting outreach to respondents throughout the round.

  • R##_REPGROUP: Replicate Group (available 2016-current round)
    • 1 = High response probability
    • 2 = Middle response probability
    • 3 = Low response probability

Variables on eligibility for incentives are constructed based on eligibility rules for a given round. All variables measuring the receipt of incentives are constructed from records of incentives that were paid to cases following completion of the interview. 

  • R##_INCENTIVE_AMT: Incentives (available 2016-current round)
    Total incentive amount paid, including Early Bird, Missed Interview and Final Push Incentives
  • R##_EB_BONUS_AMOUNT: Early Bird Bonus Amount (available 2018- current round)
    • 0 = Did not receive
    • 30 = Received
  • R##_EB_ADJACENT: Early Bird Adjacent (available 2018-current round)
    Because of operational issues (e.g., weather, mailing delays, government shutdowns, etc.), the early bird window can be expanded for some cases. This flag indicates cases that received these “adjacent” early bird payments outside of the traditional early bird window.
    • 0 = Did not receive
    • 30 = Received
  • R##_MISSED_NIR_BONUS: Missed NIR Bonus (available 2018- current round)
    • 1 = Not eligible
    • 2 = 1 round missed
    • 3 = 2 rounds missed
    • 4 = 3 or more rounds missed
  • R##_MISSED_NIR_BONUS_AMOUNT: Missed NIR Bonus Amount (available 2018- current round)
    • 0 = Completed last round
    • 20 = Missed last round
    • 30 = Missed two rounds
    • 40 = Missed three or more rounds
  • R##_ENHANCED_FINAL_PUSH: Enhanced Final Push (available 2018- current round)
    • 1 = Eligible
    • 2 = Ineligible, does not meet criteria for enhanced final push eligibility
    • 3 = Ineligible, in demographic group offered enhanced final push, but completed prior to start of enhanced final push period
  • R##_ENHANCED_FINAL_PUSH_AMOUNT: Enhanced Final Push Amount (available 2018- current round)
    • 0 = Did not receive
    • 20 = Received
  • R##_FINAL_PUSH: Final Push (available 2018- current round)
    • 1 = Eligible
    • 2 = Ineligible
  • R##_FINAL_PUSH_AMOUNT: Final Push Amount (available 2018- current round)
    • 0 = Did not receive
    • 30 = Received

In Round 29, an experiment was run on the final push incentive that randomly assigned cases into one of two groups. The first group received final push around the traditional time, whereas the second group received final push 6 weeks later. The R29_FINAL_PUSH_EXPERIMENT and R29_FINAL_PUSH_EXPERIMENT_COMPLETION variables measure the eligibility and outcome of this experiment.

  • R29_FINAL_PUSH_EXPERIMENT: R29 Final Push Experiment (available 2020 only)
    • 1 = Eligible for Phase I (Treatment Group)
    • 2 = Eligible for Phase II (Control Group)
    • 3 = Ineligible because completed/NIR prior to start of experiment
  • R29_FINAL_PUSH_EXPERIMENT_COMPLETION: R29 Final Push Experiment Completion (available 2020 only)
    • 1 = Completed during Phase I
    • 2 = Completed during Phase II
    • 3 = Completed/NIR prior to start of experiment

A small set of variables also summarizes the number of responses and the percentage of invalid responses.

  • R##_RESPONSES: R Responses (available 2016-current round)
    Total Number of Responses Provided by Case
  • R##_PCT_DK: Percent Don’t Know Responses Current Round (available 2004-current round)
    Actual percent DK responses.
  • R##_PCT_REF: Percent Refusal Responses Current Round (available 2004-current round)
    Actual percent REF responses.

Beginning in 2018, interviewer characteristics were included for all respondents who were fielded, but not interviewed, as well as interviewed respondents. For non-interviewed respondents, characteristics for the most recent interviewer assigned to the case are contained in the data where available. 

Table 1. Interviewers identified in NORC database by survey year
Year Number of Respondents Interviewed Number of Interviewers Matched Percentage Not Matched
1979 12686 9838 22.4%
1980 12141 11200 7.8%
1981 12195 11850 2.8%
1982 12123 11736 3.2%
1983 12221 11980 2.0%
1984 12069 11585 4.0%
1985 10894 10850 0.4%
1986 10655 10560 1.0%
1987 10485 10485 0.0%
1988 10465 10386 10.2%
1989 10605 9906 6.6%
1990 10436 9321 10.7%
1991 9018 8933 1.0%
1992 9016 8947 0.3%
1993 9011 8933 1.0%
1994 8891 8701 2.1%
1996 8636 8050 6.8%
1998 8399 8302 1.2%
2000 8033 7814 2.7%
2002 7726 7723 0.0%
2004 7661 6851 10.6%
2006 7654 7328 4.3%
2008 7757 7742 0.1%
2010 7565 7559 0.0%
2012 7301 7293 0.1%
2014 7071 6977 1.3%
2016 6913 6913 0.0%
2018 6878 6878 0.0%
2020 6535 6535 0.0%
2022 6413 6413 0.0%

NLSY79 Appendix 16: 1994 Recall Experiment

The Recall Experiment

Beginning with the 1996 survey, the NLSY79 became a biennial survey. In anticipation of reverting to a two-year interview period, an experiment dubbed the "Recall Experiment" was conducted in 1994 on a portion of the eligible sample. A sub-sample was drawn from the members of the original 12686 sample still eligible for interview in 1994, who were also interviewed in 1992 and 1993. This sub-sample was treated as if their 1993 interview never took place; their date of last interview was established as the 1992 interview date. The information that drove the 1994 interview was that gathered in the 1992 interview. The affected respondents were periodically reminded where applicable, that the reference date for their interview was not the 1993 interview date, but the 1992 interview date.

The result for the 854 "recall respondents" interviewed in 1994 is that retrospective information, pertaining mainly to the period since the last interview, was essentially re-reported for the period between the 1992 and 1993 interviews, in addition to the new information for the 1993-94 survey period. The re-reported information for the 1992-93 interview period can be compared to that previously reported during the 1993 interview for possible discrepancies.

The goal of this experiment was to gain a better sense of the possible consequences for respondent recall, of a biennial instead of annual survey administration, for accuracy and consistency of data and overall respondent burden of participating in the survey. Certain segments of NLSY79 surveys in specific years have previously collected retrospectives over a two-year period or longer. For example, the more detailed two-year fertility history sponsored by The National Institute for Child Health and Development (NICHD) has been administered in selected survey years. However, except in the case of a respondent who actually skips one or more interviews, retrospectives in most segments of the questionnaire for a given year, have required that a respondent only recall events and circumstances over the period of roughly a year.

Effects on NLSY79 data

Because the information for the 1992-1993 interview period was reported twice -- both during the 1993 and 1994 interviews -- users may encounter some degree of difference and inconsistency in that data gathered in 1993 and 1994. Data pertaining to past calendar year, such as spouse's labor force activity or respondent's income and assets, is not affected by the experiment. Retrospectives for which data between the 1992 and 1993 interview period would have been reported both in the 1993 and 1994 interviews is listed below.

  • Marital History
    • Retrospective/event history of changes in marital status since date of last interview
  • Regular Schooling
    • Two-year retrospective of specific months of enrollment (if any) in regular school for the 1993 calendar year only
    • Retrospective/event history of college attendance since date of last interview
  • Military
    • Retrospective/event history of military enlistment and separation dates since date of last interview
  • On Jobs/Employer Supplements
    • Retrospective/event history of employment with specific employers, and periods not working for specific employers (gaps within jobs), since date of last interview
  • Gaps
    • Retrospective/event history of periods of non-employment (gaps between employers), since date of last interview
  • Training
    • Retrospective/event history of (continued) participation since the last interview, in training programs either reported at the date of last interview or enrolled in since the date of last interview
  • Health
    • Retrospective/event history of most recent and most severe work-related injuries (if any), since date of last interview
  • Income and Assets
    • Retrospective/event history of program recipiency (respondent/spouse unemployment compensation, AFDC, government food stamps, SSI/other welfare) since either December 1992, if receipt reported during that month, or January 1993 for those not reporting receipt in December 1992

The Fertility History section is a special case with respect to the Recall Experiment. Between the 1986 and 1992 interview years, in which paper-and-pencil interviewing (PAPI) was used, information on biological children was collected in each odd-numbered year on any biological children born since the date of last interview. However, even-numbered years contained an expanded fertility history section, sponsored by NICHD. This expanded history included a re-reporting of biological children born since the date of the last NICHD interview (even-numbered year). Newly reported children were handwritten onto the records when paper-and-pencil instruments were being used. This allowed interviewers to easily identify children about whom certain series of questions should be asked. The fertility data therefore, has for years contained a limited version of the 1994 Recall Experiment, specific to biological children. Other segments of the fertility history (pregnancy information for female respondents and visitation habits of biological children with non-residential parents) were collected exclusively as two-year retrospectives in even-numbered years. With the advent of CAPI interviewing, it was decided that re-reporting of biological children in NICHD years was no longer necessary. Interviewers no longer needed to rely on visual identification of children reported since the last NICHD interview, because these children could be mechanically flagged. Therefore, in 1994, respondents not belonging to the Recall Experiment sample were for the first time since 1986, only required to report new children born since the date of last interview, instead of the last NICHD interview (two years ago in most cases). However, Recall Experiment respondents were asked to update their biological child records since the last NICHD interview year (1992), as was the norm in even-numbered years since 1986. This will continue to be the case for all respondents with the biennial administration, which began in 1996. However, the elimination of the odd-year survey also means the continued elimination of re-reporting of children born since the last NICHD interview.

Effects on auxiliary data files and variables in NLSY79

The potential seam effects introduced by the Recall Experiment are particularly relevant for the work history data file and the creation of the key variable, Total Net Family Income. In each case, a different procedure was used to eliminate possible discrepancies in information reported both during the 1993 and 1994 interviews.

Work History 1979-1994 data file

The 1979-93 release of the work history data file already incorporated information covering the period between the 1992-93 interviews in each respondent's longitudinal labor force history. The possible disruptions that might occur to the longitudinal record, if inconsistent data were introduced into the formulas for a single time frame, were unpredictable and potentially serious. It was determined that information covering the period between the 1992 and 1993 interview, reported by the recall respondents in the 1994 interview, would be eliminated for the purposes of creating the 1979-94 work history file. The following basic decision rules were applied:

  1. Data pertaining to employers, gaps in employment and/or periods of military service for which the start and stop dates fell completely prior to the 1993 interview date for recall respondents were completely eliminated for the purposes of creating the 1979-94 work history data file. These should have been reported during the original 1993 interview;
  2. Data pertaining to employers, gaps in employment and/or periods military service for which the start and stop dates fell completely within the period between the 1993 and 1994 interview were retained in their entirety. These constitute new information and would not have been reported during the 1993 interview;
  3. Data pertaining to employers, gaps in employment and/or periods military service for which the start and stop dates fell partially prior and partially after the 1993 interview date, was truncated where necessary at the 1993 interview date (e.g. start dates of these periods of employment/non-employment were set to the 1993 interview date).

Users should note that, with respect to gaps in employment, the NLSY79 does not establish specific weeks when a respondent might be looking for work or laid off (making him/her unemployed as opposed to out of the labor force or OLF). Respondents report only a total number of weeks during each gap for each status. This made it impossible to determine which segment of the 1992-94 interview period should be assigned the unemployed code and which the OLF code for gaps which fell partially prior and partially after the 1993 interview, and in which the respondent reported both statuses.

Total Net Family Income

For the purposes of creating Total Net Family Income, the total number of weeks/months of program recipiency in the past calendar year (1993) and the average amount received per week/month in 1993 are required. Recall respondents would have reported all 1993 recipiency in the 1994 interview, not just that occurring prior to the 1993 interview date. Therefore, 1994 data was used exclusively to compute the total 1993 recipiency figures for the recall respondents. This avoided the task of attempting to combine data from 1993 and 1994 for these respondents and deal with potential inconsistencies in reports between the two interviews.

NLSY79 Appendix 15: Recipiency Event History Data

The NLSY79 surveys have solicited information about program recipiency since the first round in 1979. Methods used to collect information about program recipiency from 1979-1992 and from 1993 to the present differed. These methods are described below. The variables found in the RECIPIENT MONTH and RECIPIENT YEAR areas of interest have been constructed to provide users with a more straightforward sequence of variables containing monthly and yearly receipt amounts (if any) and flags for the survey year in which the data was reported. The roots of these question names are contained in the table below. Recipiency event history variables exist for five types of recipiency (question name roots in parentheses): AFDC (Q13A-), Food Stamps (Q13F-), SSI/SSDI/other public assistance/welfare (Q13SSI-), unemployment compensation (Q13U-), and spouse/partner unemployment compensation (Q13S-). Since survey year 2018, respondents have been asked to distinguish between SSI and SSDI if possible. Array items are present from January 2017 through the current interview.

Recipient Month Question Name Roots Recipient Year Question Name Roots
UNEMPR-[MOYR]-AMT UNEMPR-TOTAL-[YEAR]
UNEMPSP-[MOYR]-AMT UNEMPSP-TOTAL-[YEAR]
AFDC-[MOYR]-AMT AFDC-TOTAL-[YEAR]
FDSTMPS-[MOYR]-AMT FDSTMPS-TOTAL-[YEAR]
SSI-[MOYR]-AMT SSI-TOTAL-[YEAR]
SSDI-[MOYR]-AMT SSDI-TOTAL-[YEAR]
[MOYR]-RECIP-FILL WELFARE-AMT-[YEAR]

The current NLSY79 release contains revised recipiency event history data for survey years 1979-2002. Some anomalies in the construction of the recipiency event history data in previous releases necessitated these revisions. Researchers should use only the recipiency variables with reference numbers beginning with "G." These include the revised variables for survey years 1979-2002 (containing data from calendar years 1978 through the 2002 interview) and the most up-to-date data series for 2003 through the most recent survey. The unrevised original series has been included in the release as a non-primary set of variables for historical purposes.

This appendix first contrasts the collection of information on recipiency in the paper and pencil interviewing (PAPI) years (1979-1992) to that of the computer-assisted personal interviewing (CAPI) years (1993-present). It then describes the creation processes for the recipiency event history variables. A discussion of the kinds of problems necessitating the revisions is available in Errata Description for Original 1979-2002 Recipiency Variables.

Program recipiency in paper-and-pencil interviews

In paper-and-pencil (PAPI) NLSY79 rounds (1992 and prior), information on R and spouse unemployment compensation, AFDC, Food Stamps and other welfare recipiency was gathered for the calendar year prior to the interview year only. For instance, someone interviewed in 1992 was asked about the months of recipiency in 1991 only. An average figure per week/month was then asked for the entirety of 1991. For example, if a respondent said s/he was receiving AFDC in March, April and May of 1991, and again in September and October of 1991, s/he was only asked for an average amount per month received during those months in 1991.

Data collected in this manner generates a complete event history only for respondents who were interviewed at each interview date. For those respondents, information would be present for each month benefits were received from January 1978 through December 1991 (the year before the 1992 interview). However, a respondent skipping one or more interviews would be missing information for each calendar year preceding missed interview years. For example, a respondent missing the 1985 and 1990 interviews would be missing recipiency information for calendar years 1984 and 1989.

Program recipiency in CAPI interviews

In the computer-assisted-personal-interviewing (CAPI) NLSY79 rounds (1993 - present) respondents are asked about receipt from government programs since their last interview. Surveys through the 1990s (1993, 1994, 1996 and 1998) also contain some specialized questions to aid the transition from the previous method to the current method of collection and to minimize the number of respondents with any interruptions in their month-to-month event histories.

Respondents are now asked if they have received benefits at all since their date of last interview. Individuals who report no recipiency since their last interview year to the next section of the interview. If the respondent answers "yes," s/he is then asked for the date when the benefits began. This is considered the first spell. Respondents are then asked if benefits have been received continuously since this start date. If the respondent answers "yes," receipt has been continuous, s/he is asked for the average dollar amount received per month/week for each year in the spell. These respondents then proceed to the next section of the interview. If the respondent answers that receipt has not been continuous since this first start date, s/he is asked to report the first date s/he stopped receiving benefits. Average dollar figures per month/week are collected for each year within this first spell.

All respondents who report completing a first spell since their last interview are asked if they started receiving benefits again since the first spell ended. In the 1993, 1994 and 1996 survey years, Information on up to five spells is collected in the manner described above. If there are more than five spells, the respondent is asked about the first five and the most recent. Beginning in 1998, respondents were asked about all spells of receipt.

In interviews following the initial CAPI interview (1993 in most cases), respondents are asked to verify the last month they reported receiving benefits (if any). They are then asked about any recipiency since their date of last interview. In the electronic questionnaires, the retrospective recipiency event history is collected from the date of the last interview, providing a more continuous longitudinal record, even for respondents who skip interviews.

The flow of questions in the recipiency modules is illustrated in Figure A15.1.

Figure A15.1 Flow of program recipiency questions in CAPI interviews

recipiency questionnaire flowchart

Read an outline version of the flowchart

In the 2018 survey, some updates were made to the Income module of the questionnaire, including some relatively minor updates to the recipiency-related segments. While the structure of each of the recipiency question series remained essentially the same, the SSI questions (beginning with Q13SSI-) were split into separate segments for the respondent and/or any dependent children (Q13SSI-), and a spouse/partner (Q13SSI-SP-) if applicable. In addition, respondents were asked to differentiate between SSI and SSDI if they know which they are receiving. In addition, specification was added to the TANF segment of questions (beginning with Q13A-) to specify that the questions refer to dependent children where applicable. Finally, language referencing SNAP was added to the Food Stamps segment of questions (Q13F-) as the program has been renamed.

Variable creation

PAPI interviews

For most of the PAPI years, the yearly and monthly receipt/non-receipt variables are taken directly from responses, and the average monthly value of benefits is used for each month that the respondent reports receiving benefits. For unemployment compensation, weekly averages were collected. This weekly average was multiplied by 4.3 and then used as the monthly average. However, there are two main exceptions to this. First, the Food Stamp program underwent a change in 1979. Prior to this, recipients were allowed to purchase food stamps at a price below their market value. Because the 1979 interview asked respondents about recipiency in 1978, respondents who reported receiving food stamps were asked how much they paid for the food stamps in addition to the dollar value of the food stamps received in the last month they received benefits in 1978. The net transfer for 1979 is estimated by subtracting the dollar amount paid from the dollar value received. In all subsequent years, respondents were only asked for the dollar value received in the last month of the previous year that benefits were received.

The second exception concerns SSI and other forms of public assistance/welfare. The series of questions pertaining to public assistance/welfare and SSI has undergone some changes since the beginning of the survey. Initially, in 1979, respondents were asked in a single question if they had received income from any of the sources mentioned above. Respondents were also asked in which months benefits were received and the average amount received each month. They were then asked to identify from which sources they received benefits. However, it is not possible to identify how much of this amount is attributable to each source if more than one source was reported.

From 1980 through 1984, the question was divided into two separate ones. Respondents were first asked if they had received any benefits from SSI in the preceding year. They were then asked in which months benefits were received and the average amount received each month. A second set of questions asked respondents if they had received public assistance/welfare in the preceding year and, if so, in which months and the average amount received each month.

The format of the questions was changed once again in 1985 and remained the same through 1996. As with the initial interview in 1979, respondents were asked if they had received any benefits from SSI, public assistance/welfare. They were then asked in which months benefits were received and the average amount received each month. However, unlike the 1979 interview, respondents were not asked to identify the source of the benefits.

In 1998, to address major welfare reform policies passed in 1996, the series was altered once again. Respondents were asked first about SSI receipt only. A separate series of questions was added to solicit information on other types of general public assistance.

The final changes were made for the 2000 interview and have been in effect since that time. Information on other forms of public assistance was curtailed significantly. The series of questions collecting information about SSI remained in the instrument.

Users should be aware that the responses since the 2000 interview contain the least amount of information, pertaining to SSI receipt. This is reflected in the recipiency event history variables since 2000 as well.

CAPI interviews

Due to the way PAPI interviews collected data (for the calendar year prior to the survey year), information on recipiency is available beginning with January of 1978. Designating this to be month 1 of the monthly event history, all start and stop dates can be identified by their month number. This may be easily calculated using the following algorithm: month_# = (year - 1978) x 12 + month. For instance, June of 1993 would be: (1993 - 1978) x 12 + 6 = 186. Once all start and stop dates have been calculated, the event history for each individual can be created.

To illustrate this, consider Case 1 from Table A15.1. This respondent was not interviewed in 1992 which means that her/his event history from the PAPI survey years would contain information up through December of 1990. Thus, the beginning month of the CAPI event history would be January of 1991 (month 157). According to the example, this respondent was receiving benefits in December of 1991 and continued to do so until June of 1991 (month 162) and then received no further benefits. The dollar amount event history would then be formed by placing dollar value reported for the average benefits in 1991, $135, into months 157 - 162 and zeros into the dollar amounts for months 163 - 186. This same logic can be applied to each respondent, regardless of the number of reported spells of recipiency: placing reported dollar amounts into all months within a spell (from start_spell(i) to stop_spell(i) ) and zeros into all months outside of spells (1 + stop_spell(i) to start_spell(i+1) -1).

To illustrate more completely how each respondent's event history was created, Table A15.1 depicts four additional hypothetical cases. Cases 2 and 4 represent respondents who receive continuously after their start dates; Case 3 depicts a respondent who reports no benefit receipt; and Case 5 represents a respondent who reports two completed spells of recipiency. Table A15.2 presents the event histories which would result if the information had been given by the respondents portrayed in Table A15.1.

Table A15.1 Five hypothetical CAPI cases

Question

Case #1 Case #2 Case #3 Case #4 Case #5

Interview date

6/93 6/93 10/93 7/93 8/93

Year of last interview

1991 1991 1991 1991 1991

Receive Dec year before last interview?

Y Y N N N

Spell_0 continuous?

N Y      

First stop date spell_0

6/91        

Average monthly/weekly benefits in '91 months (rec'd Dec or year before last int)

135        

Receive since Jan of last interview?

    N Y Y

Start date spell_1

      3/91 3/91

New spell since stop date spell_0

         

Start date spell_1

         

Spell_1 continuous?

      Y N

Stop date spell_1

        9/91

Average monthly/weekly benefits in '91 months (1st new spell)

        200

New spell since stop date spell_1?

        Y

Start date spell_2

        2/93

Spell_2 continuous?

        N

Stop date spell_2

        5/93

Average monthly/weekly benefits in '93 months (2nd new spell)

        225

New spell since stop date spell_2?

        N

Average monthly/weekly benefits in '91 months (rec'd contn'ly since last start date)

  145   157  

Average monthly/weekly benefits in '92 months (rec'd contn'ly since last start date)

  152   160  

Average monthly/weekly benefits in '93 months (rec'd contn'ly since last start date)

  175   163  
Table A15.2. Resultant event histories
Month/Year Case #1
Dollar
Case #2
Dollar
Case #3
Dollar
Case #4
Dollar
Case #5
Dollar
1/91 135 145 0 0 0
2/91 135 145 0 0 0
3/91 135 145 0 157 200
4/91 135 145 0 157 200
5/91 135 145 0 157 200
6/91 135 145 0 157 200
7/91 0 145 0 157 200
8/91 0 145 0 157 200
9/91 0 145 0 157 200
10/91 0 145 0 157 0
11/91 0 145 0 157 0
12/91 0 145 0 157 0
1/92 0 152 0 160 0
2/92 0 152 0 160 0
3/92 0 152 0 160 0
4/92 0 152 0 160 0
5/92 0 152 0 160 0
6/92 0 152 0 160 0
7/92 0 152 0 160 0
8/92 0 152 0 160 0
9/92 0 152 0 160 0
10/92 0 152 0 160 0
11/92 0 152 0 160 0
12/92 0 152 0 160 0
1/93 0 175 0 163 0
2/93 0 175 0 163 225
3/93 0 175 0 163 225
4/93 0 175 0 163 225
5/93 0 175 0 163 225
6/93 0 175 0 163 0
7/93 -4 -4 0 163 0
8/93 -4 -4 0 -4 0
9/93 -4 -4 0 -4 -4
10/93 -4 -4 0 -4 -4
11/93 -4 -4 -4 -4 -4
12/93 -4 -4 -4 -4 -4

In each CAPI interview from 1993 through the present survey year, information is collected for all time up to the current interview date. Because all respondents are not interviewed in the same month, the resultant event histories would be of unequal length. In order to avoid this, a -4 is placed into each monthly dollar value from the month following the interview month to last month of the field period for the most recent survey. These -4s function merely as place savers and will be replaced by information collected from the next interview. For example, if the respondent represented by Case 1 is interviewed in September of 1994 and reports no benefit receipt since the last year, then the -4s for July to December of 1993 become 0s and -4s are placed in the dollar values for October to December of 1994. These new -4s would later be replaced by information from the 1996 interview.

Handling don't knows and refusals

In PAPI years when the respondent did not know whether s/he had received benefits in the previous year, a "-2" was placed in all months and dollar values for that year. For respondents who refused to answer this question, "-1" was entered into all months and dollar values for that year.

In CAPI years, when asked for the start or stop date of a spell, a respondent could respond "don't know." When the respondent does not know (or refuses to answer) the start date of a spell of recipiency, s/he is then asked approximately how many months/weeks s/he received benefits and how much s/he received in the last month/week s/he received benefits. If a respondent does not know the start date and there are valid responses for these questions (i.e., responses greater than zero), the start date is set at the first possible point of the unfilled event history and "-2" is placed into the months that the respondent reports receiving. For example, if a respondent last interviewed in 1990 and being interviewed in 1993 responds that s/he has received benefits since January of the last interview year but does not know when s/he started receiving, the start date is set at January of 1990. If this same respondent reports that s/he received benefits for six months and received $200 the last month s/he received benefits, then "-2" would be filled into the January through June of 1990 dollar values for these months. The dollar value monthly variable for July 1990 through the interview date would then be filled with zeros. If the respondent does not know the stop date but has reported a start date, the same logic is employed using the reported start date.

Fill flags

The recipiency variables have been assigned an XRND survey year classification. The electronic questionnaire format collects recipiency information from years when an individual has missed an interview. This allows variables for past years to be updated with data from the most recent survey, similar to the Work History arrays. The traditional non-interview code "-5" is not found in these data. In order to identify the "true" non-interviews in each year, a series of fill flags have been created. These are monthly variables which indicate the interview year from which the information was collected. For the vast majority of the PAPI years, the data will have come from the interview after that calendar year, i.e., data for March 1985 will have been provided in the 1986 interview. Respondents for whom variables representing months between 1978 and 1991 that are not filled in this manner (from the interview year after that calendar year) will have generally missed a number of interviews and had their information filled in from a CAPI survey year years later, when the event history format began collecting data from the date of last interview.

Programs for Recipiency Event Histories (survey year 2022)

Click below to view programming code.

Respondent Unemployment Benefits Receipt

%let cEndYr = 123;		*(2023-1900);
%let cEndMo = 1488;     *(123+1)*12;
%let cYrs = 46;			*(2023-1978)+1;
%let cMos = 552;		*46*12;
%let cFillFlag = 2022;
data Q13;
 set prg2022.in_inc_2022;
 
VARIABLE NAMES IN PUBLIC RELEASE		VARIABLE NAMES IN PROGRAM
  Q13RECIP-2_2022       			RECIP2                                      
  Q13U-43B_2022         			q43B
  Q13U-43C~M_2022       			q43CM
  Q13U-43C~Y_2022       			q43CY
  Q13U-44A1_CHK1.01_2022			q44A1CHK101
  Q13U-44A1_CHK1.02_2022			q44A1CHK102
  Q13U-44A1_CHK1.03_2022			q44A1CHK103
  Q13U-44A1_CHK1.04_2022			q44A1CHK104
  Q13U-44A3.01_2022     			q44A301
  Q13U-44A3.02_2022     			q44A302
  Q13U-44A3.03_2022     			q44A303
  Q13U-44A3.04_2022    				q44A304
  Q13U-44A5.01_2022     			q44A501
  Q13U-44A6.01_2022     			q44A601
  Q13U-44B.01_2022    				q44B01
  Q13U-44B.02_2022      			q44B02
  Q13U-44B.03_2022      			q44B03
  Q13U-44B.04_2022      			q44B04
  Q13U-44C.02~M_2022    			q44C02M
  Q13U-44C.02~Y_2022    			q44C02Y
  Q13U-44C.03~M_2022    			q44C03M
  Q13U-44C.03~Y_2022    			q44C03Y
  Q13U-44C.04~M_2022    			q44C04M
  Q13U-44C.04~Y_2022    			q44C04Y
  Q13U-44D.01_2022      			q44D01
  Q13U-44D.02_2022      			q44D02
  Q13U-44D.03_2022      			q44D03
  Q13U-44D.04_2022      			q44D04
  Q13U-45A.01_2022      			q45A01
  Q13U-45A.02_2022      			q45A02
  Q13U-45A.03_2022      			q45A03
  Q13U-45A.04_2022      			q45A04
  Q13U-45B.01~M_2022    			q45B01M
  Q13U-45B.01~Y_2022    			q45B01Y
  Q13U-45B.02~M_2022    			q45B02M
  Q13U-45B.02~Y_2022    			q45B02Y
  Q13U-45B.03~M_2022    			q45B03M
  Q13U-45B.03~Y_2022    			q45B03Y
  Q13U-45B.04~M_2022    			q45B04M
  Q13U-45B.04~Y_2022    			q45B04Y
  Q13U-47E.01_2022      			q47E01
  Q13U-47E.02_2022      			q47E02
  Q13U-47E.03_2022      			q47E03
  Q13U-47E.04_2022      			q47E04
  Q13U-62.01_2022       			q6201
  Q13U-62.02_2022       			q6202
  Q13U-62.03_2022       			q6203
  Q13U-62.04_2022       			q6204
  Q13U-62A.01_2022      			q62A01
  Q13U-62A.02_2022      			q62A02
  Q13U-62A.03_2022      			q62A03
  Q13U-62A.04_2022      			q62A04
  Q13U-63.01_2022       			q6301
  Q13U-63A.01_2022      			q63A01
  Q13U-63AA.01_2022     			q63AA01
  Q13U-63B.01_2022      			q63B01
  Q13U-64.01_2022       			q6401
  Q13U-64.02_2022       			q6402
  Q13U-64.03_2022       			q6403
  Q13U-64.04_2022       			q6404
  CURDATE~D_2022        			intDay     
  CURDATE~M_2022        			intMo 
  CURDATE~Y_2022        			intYr
  
data recip1;
 merge R30.lintdate2022 Q13 prg2022.oldin2022 (keep=norcid uydolo:);
 by norcid;
 if (intMo > 0); 
recip = RECIP2;
                   
data recip;
 set recip1;
 
* convert Y2K changes to simple years;
array yrs (*) intYr q43cy
              q44c01y q44c02y q44c03y q44c04y 
              q45b01y q45b02y q45b03y q45b04y;
do i=1 to dim(yrs);
    if yrs(i) > 0 then yrs(i)=yrs(i)-1900;
end;
* date of this interview;
intDt=intYr*12+intMo;
/* ==========================================================================
  Merge info from several sources + convert weeks to months.
  ========================================================================== */
dummy1 = -4; 
dummy2 = -4; 
dummy3 = -4; 
if q44c01y>-4 and q43cy>-4 and q44c01y<q43cy then do;
	q44c01y=q43cy;
	q44c01m=q43cm;
end;
else if q44c01y>-4 and q43cy>-4 and q44c01y>q43cy then do;
	q44c01y=q44c01y;
	q44c01m=q44c01m;
end;
else if q44c01y>-4 and q43cy>-4 and q44c01y=q43cy then do;
	q44c01m = max(q44c01m, q43cm);
	q44c01y = max(q44c01y, q43cy);
end;
else if q44c01y<=-4 and q43cy>-4 then do;
	q44c01m = max(q44c01m, q43cm);
	q44c01y = max(q44c01y, q43cy);
end;
/* nrOfRMo - # of months x was received (used when start/stop dates are not known).*/
array nrOfRMos  (*) q63a01 dummy1 dummy2 dummy3;
nrOfRMos(1) = max(nrOfRMos(1), q63aa01, q63ab01);
do s = 1 to dim(nrOfRMos);
    if nrOfRMos(s) > 0 then
        nrOfRMos(s) = max(round(nrOfRMos(s)/4.3),1);  
end;
* How much did R get during each month (by spells);
array howMuch (*) q47e01-q47e04;   
array q63b    (*) q63b01-q63b04;   
do s=1 to dim(howMuch);
    if howMuch(s) = -4 then howMuch(s) = q63b(s);             
    if howMuch(s) > 0 then howMuch(s)=round(howMuch(s)*4.3,1);
end;
/* ==========================================================================
   Recipiency status (rec) and amounts (dol) by months
   All months from 1978jan till dec of current year, indexed from 1900jan.
   78*12+1 = 937
   ========================================================================== */
array rec (937:&cEndMo);      * Did they receive x in that month?;
array dol (937:&cEndMo);      * How much?;
/* ========================================================================== 
 * No/unknown recipiency
 * ========================================================================== */
if recip=0 then do;
    do m=lint to intDt;
        rec(m)=-4;
        dol(m)=-4;
    end;
end;
else if recip in (-1,-2) then do;
    do m=lint to intDt;
        rec(m) = Recip;
        dol(m) = Recip;
    end;
end;
else if recip in (-3) then do;
    do m=lint to intDt;
        rec(m) = Recip;
        dol(m) = Recip;
    end;
end;
/* ==========================================================================
 * There was some recipiency, get details 
 * ========================================================================== */
else do;
check = 0;
array startMo (*) q44c01m q44c02m q44c03m q44c04m;
array startYr (*) q44c01y q44c02y q44c03y q44c04y;
array endMo (*) q45b01m q45b02m q45b03m q45b04m;
array endYr (*) q45b01y q45b02y q45b03y q45b04y;
array cont    (*) q44d01-q44d04;
array q44b    (*) q44b01-q44b04;
array q64     (*) q6401-q6404;  
/* ==========================================================================
 * Calculate starts and ends of spells if possible
 * ========================================================================== */
array starts (*) starts1-starts4; 
array ends   (*) ends1-ends4;     
* Continuous recipiency "ends" at interview date;
do s = 1 to dim(cont);
    if cont(s) = 1 then do;
        endYr(s) = intYr;
        endMo(s) = intMo;
    end;
end;
* Compute starts/stops/last for basic cases (dates are known);
do s = 1 to dim(starts);
    if startMo(s) > 0 & startYr(s) > 0 then
        starts(s) = startYr(s)*12+startMo(s);
    if endMo(s) > 0 & endYr(s) > 0 then
        ends(s) = endYr(s)*12+endMo(s);
end;
seamFlag=0;
do s = 1 to dim(starts);
	if starts(s) > 0 then do;
        if starts(s)=lint   then seamFlag=1;   
        if starts(s)=lint-1 then seamFlag=2;   
		if 0<starts(s)<lint-1 then seamFlag=3; 
	end;
end;
lint_real=lint-936-1;
do s=1 to dim(starts);
  if starts(s) > 0 & starts(s)<lint then starts(s)=lint;
end;
* Try to deduce starts/ends from # of mos;
do s = 1 to dim(starts);
    if nrOfRMos(s) > 0 then do; 
        if ends(s) > 0 then do;
            starts(s) = ends(s) - nrOfRMos(s)+1;
			check=5.1;
            if (starts(s) < lint) then check = 5;  
        end;
        else if starts(s) > 0 then do;
            ends(s) = starts(s) + nrOfRMos(s) - 1;
			check=100+s+0.1;  
			if ends(s)>intDt then check=100+s; 
        end;
		else if starts(s) = .  & ends(s) = .  then do; 
            if s = 1 then do; starts(s) = lint; check=201+0.1; end;   
			else do; starts(s) = ends(s-1) + 1; check=200+s+0.1; end; 
            ends(s) = starts(s) + nrOfRMos(s) - 1;
			if ends(s)>intDt then check=200+s; 
        end;
    end;
end;
last = 0;
if q44b01=2 or q43B = 2 then last = 1;
do s = 1 to dim(starts);
    if ((startMo(s) > 0 | startYr(s) > 0 | endMo(s) > 0 | endYr(s) > 0 |nrOfRMos (s) > 0) & last < s) then last = s;
end;
/* -----------------------------------------------------------------------------
 * Edges of recipiency spells and periods between: n1 r1 n2 r2 ...  (NNNRRR???NRRR)
 * Under ideal conditions they touch, but often there is an unclear zone between them (-2)
 * ----------------------------------------------------------------------------- */
array rs(*) rs1-rs4;        * Recipiency starts;
array re(*) re1-re4;        * Recipiency ends;
array ns(*) ns1-ns5;        * Nonrecipiency starts (# of spells + 1, potentialy bef and after);
array ne(*) ne1-ne5;        * Nonrecipiency ends;
* The fully known cases;
do s = 1 to last;
    if starts(s) > 0 then do;
        ne(s) = starts(s)-1;
        rs(s) = starts(s);
    end;
    if ends(s) > 0 then do;
        re(s)   = ends(s);
        ns(s+1) = ends(s)+1;
    end;
end;
* The unknown and partially known cases;
do s = 1 to last;
    if starts(s) = . & startYr(s) > 0 then do; 
		check=301; 
        xne = startYr(s)*12; 
        if ( s = 1 & lint < =xne ) |
           ( s > 1 & 0 < ends(s-1) < xne) |
           ( s > 1 & 0 < endYr(s-1) + 1 < startYr(s) )
            then do; ne(s) = xne; check=302; end;  
        if startYr(s) < endYr(s) then do;
            rs(s) = startYr(s)*12+12;  
			check=303; 
		end;
    end;
    
    if (ends(s) = . & endYr(s) > 0) then do; 
		check=401;  
        if 0 < startYr(s) < endYr(s) then do;
            re(s) = endYr(s)*12+1;        
            ns(s+1) = endYr(s)*12+13;     
			check=402; 
		end;
		if 0 < startYr(s) = endYr(s) then do; 
          ns(s+1)=endYr(s)*12+13; 		
		  if rs(s)>0 then do;
			re(s)=rs(s); 
		  end;
		  check=403;
		end;
    end;
end;
if (ne(1) > 0) then ns(1) = lint;               * There was a nonrecipiency at the begining;
if (ns(last+1) > 0) then ne(last+1) = intDt;    * There was a nonrecipiency at the end;
if last>=2 then do s = 2 to last;
	if 0 < rs(s) & rs(s) = re(s-1) then check = 7;
end;
 if rs1 > 0 & rs1<lint then rs1=lint;
 
/* -----------------------------------------------------------------------------
 * Fill the recipiency status (rec) and amounts (dol).
 * ----------------------------------------------------------------------------- */
* First, assume we know nothing;
do m = lint to intDt;
    rec(m) = -2;
    dol(m) = -2;
end;
* Fill in info we know (any of the periods below can be empty);
do s = 1 to last;
    * nonrecipiency period;
    if (0 < ns(s) <= ne(s)) then
        do m = max(ns(s),lint) to min(ne(s),intDt);
            rec(m) = -4;
            dol(m) = -4;
        end;
    * recipiency period;
    if (0 < rs(s) <= re(s)) then
        do m = max(rs(s),lint) to min(re(s),intDt);
            rec(m) = 1;
            dol(m) = howMuch(s);
			if howmuch(s) in (. -4) then do; dol(m)=-2; check5=s+0.1; end; 
        end;
    * we know only start - we are sure R received smth that month;
    else if (lint <= rs(s) <= intDt & re(s) = .) then do;  
        rec(rs(s)) = 1;
        dol(rs(s)) = howMuch(s);
        if howmuch(s) in (. -4) then do; dol(rs(s))=-2; check5=s+0.2; end; 
    end;
    * we know only end - we are sure R received smth that month (can be even intDt if continuous);
    else if (rs(s) = . & lint <= re(s) <= intDt) then do;
        rec(re(s)) = 1;
        dol(re(s)) = howMuch(s);
		if howmuch(s) in (. -4) then do; dol(re(s))=-2; check5=s+0.3; end;
    end;
end;
* The last period of nonrecipiency;
if (0 < ns(last+1) <= ne(last+1)) then
    do m = ns(last+1) to min(ne(last+1),intDt);
        rec(m) = -4;
        dol(m) = -4;
    end;
end;
/* ========================================================================== */
/* End if recip = .... (getting details for people who got something)
/* ========================================================================== */
do m=intDt+1 to hbound(rec);
    rec(m)=-4;
    dol(m)=-4;
end;
endDt=intDt-936;
noInt=0;
if q44c01m in (-1,-2) & q44c01y in (-1,-2) then q43b = 2;
if noInt=0 then
    do i=lbound(rec) to hbound(rec);
        if rec(i)=. then rec(i)=-4;
        if dol(i)=. then dol(i)=-4;
    end;
if noInt=1 then
    do i=lbound(rec) to hbound(rec);
        if rec(i)=. then rec(i)=-5;
        if dol(i)=. then dol(i)=-5;
    end;
    
/* ==========================================================================
 * Calculating yearly variables.
 * ========================================================================== */
array recYM(&cYrs,12) rec1-rec&cMos;
array dolYM(&cYrs,12) dol1-dol&cMos;
array yRec(*)   yRec78-yRec&cEndYr;
array yDol(*)   yDol78-yDol&cEndYr;
array yRecMo(*) yRecMo78-yRecMo&cEndYr;
* Calculate yRec (any recipiency in a yr?);
do y=1 to dim(yRec);
    do m=1 to 12;
        if recYM(y,m) ~= . then    yRec(y)=0;
        if recYM(y,m) > 0 then do; yRec(y)=1; leave; end;
    end;
	if yRec(y)=0 then do m=1 to 12;
	    if recYM(y,m) in (-1 -2 -3) then do;  yRec(y)=recYM(y,m); leave; end;
	end;
	if yRec(y)=0 then yRec(y)=-4; 	
end;
* Calculate yDol ($ in yr), yRecMo (# of months of recipiency in each y);
do y=1 to dim(yRec);
    if yRec(y) > 0 then do;
		rrefuse = 0; drefuse = 0;
		rdk = 0;     ddk = 0;
        do m=1 to 12;
			if dolYM(y,m) = -1 then drefuse = 1;
			else if dolYM(y,m) in (-2 -3) then ddk = 1;
            if recYM(y,m) = -1 then rrefuse = 1;
			else if recYM(y,m) = -2 then rdk = 1;
		end;
		if rrefuse = 1 then yRecMo(y) = -1;
		else if rdk = 1 then yRecMo(y) = -2;
		else do;
	        yRecMo(y) = 0;
	        do m=1 to 12;
	            if recYM(y,m) = 1 then yRecMo(y)=yRecMo(y)+1;
	        end;
	    end;
 	    if rrefuse = 1 or drefuse = 1 then yDol(y) = -3;
		else if rdk = 1 or ddk = 1 then yDol(y) = -3;   
		else do;
	        yDol(y) = 0;
	        do m=1 to 12;
	            if 0 <= dolYM(y,m) then yDol(y)=yDol(y)+dolYM(y,m); 
	        end;
	    end;
	end;
	else do;
		yDol(y)=yRec(y);
		yRecMo(y)=yRec(y);
	end;
end;
/* ==========================================================================
 *  Flag yearly amount that are not within possible bounds.
  * ========================================================================== */
array yFlg(*)   yFlg78-yFlg&cEndYr; 
array cMinDol (&cYrs) _temporary_
    (36 40 43 48 50 49 51 54 56 58 61 65 68 70 70 72 74 76 76 88 88 98 98 23*109);
array cMaxDol (&cYrs) _temporary_
    (158 173 187 208 217 215 222 236 245 254 266 284 298 305 305 315 322 333 333 383 383 433 433 7*483 3*525 550 575 11*653);
    
do y=1 to dim(yRec);
    yFlg(y) = 0; 
    if yRec(y) = -5 then yFlg(y)=-5;
    if yDol(y) < 0 then continue; 
	avgDol = yDol(y) / yRecMo(y);
    if avgDol < cMinDol(y)*4.3 then
		yFlg(y)=1;
	else if cMaxDol(y)*4.3 < avgDol then do;
        yFlg(y)=2;
		if cMinDol(y)*4.3 <= avgDol / yRecMo(y) <= cMaxDol(y)*4.3 then yFlg(y)=3;
    end;
end;
/* ==========================================================================
 *     DOL yearly amount
 * ========================================================================== */
do y=1 to dim(yRec);
    if yDol(y) = .  then yDol(y)=-4;
    if yRec(y) = -4 then yRec(y)=0;
end;
yflag=0;
array ydolo(*)   uyDolo78-uyDolo&cEndYr;
do i=1 to dim(ydol);
 if lintyr=i+77 & 0<lintmo<13 then do;
  if ydol(i)=-4 then do; ydol(i)=ydolo(i); yflag=1; end;
  else if ydol(i)>=0 & ydolo(i) not in (-4 0) then do;
    if ydolo(i)>0 then do; ydol(i)=ydol(i)+ydolo(i); yflag=2; end;
	else if ydolo(i) in (-1 -2 -3) then do; ydol(i)=ydolo(i); yflag=3; end;
  end;
 end;
end;

Spouse/Partner Unemployment Benefits Receipt

%let cEndYr = 123;		*(2023-1900);
%let cEndMo = 1488;     *(123+1)*12;
%let cYrs = 46;			*(2023-1978)+1;
%let cMos = 552;		*46*12;
%let cFillFlag = 2022;
data Q13;
 set prg2022.in_inc_2022;
  
VARIABLE NAMES IN PUBLIC RELEASE		VARIABLE NAMES IN PROGRAM
  Q13RECIP-2-SP_2022'n  					RECIP2
  Q13S-43B_2022         					q43B
  Q13S-43C~M_2022       					q43CM
  Q13S-43C~Y_2022       					q43CY
  Q13S-44A1_CHK1.01_2022					q44A1CHK101
  Q13S-44A1_CHK1.02_2022					q44A1CHK102
  Q13S-44A1_CHK1.03_2022					q44A1CHK103
  Q13S-44A1_CHK1.04_2022					q44A1CHK104
  Q13S-44A3.01_2022     					q44A301
  Q13S-44A3.02_2022     					q44A302
  Q13S-44A3.03_2022     					q44A303
  Q13S-44A3.04_2022     					q44A304
  Q13S-44A5.01_2022     					q44A501
  Q13S-44A6.01_2022    						q44A601
  Q13S-44B.01_2022      					q44B01
  Q13S-44B.02_2022      					q44B02
  Q13S-44B.03_2022      					q44B03
  Q13S-44B.04_2022      					q44B04
  Q13S-44C.02~M_2022    					q44C02M
  Q13S-44C.02~Y_2022    					q44C02Y
  Q13S-44C.03~M_2022   						q44C03M
  Q13S-44C.03~Y_2022    					q44C03Y
  Q13S-44C.04~M_2022    					q44C04M
  Q13S-44C.04~Y_2022    					q44C04Y
  Q13S-44D.01_2022      					q44D01
  Q13S-44D.02_2022      					q44D02
  Q13S-44D.03_2022      					q44D03
  Q13S-44D.04_2022     						q44D04
  Q13S-45A.01_2022      					q45A01
  Q13S-45A.02_2022      					q45A02
  Q13S-45A.03_2022      					q45A03
  Q13S-45A.04_2022      					q45A04
  Q13S-45B.01~M_2022    					q45B01M
  Q13S-45B.01~Y_2022    					q45B01Y
  Q13S-45B.02~M_2022   						q45B02M
  Q13S-45B.02~Y_2022    					q45B02Y
  Q13S-45B.03~M_2022    					q45B03M
  Q13S-45B.03~Y_2022    					q45B03Y
  Q13S-45B.04~M_2022    					q45B04M
  Q13S-45B.04~Y_2022    					q45B04Y
  Q13S-47E.01_2022     						q47E01
  Q13S-47E.02_2022      					q47E02
  Q13S-47E.03_2022      					q47E03
  Q13S-47E.04_2022      					q47E04
  Q13S-62.01_2022       					q6201
  Q13S-62.02_2022       					q6202
  Q13S-62.03_2022       					q6203
  Q13S-62.04_2022      						q6204
  Q13S-62A.01_2022     						q62A01
  Q13S-62A.02_2022     						q62A02
  Q13S-62A.03_2022     						q62A03
  Q13S-62A.04_2022     						q62A04
  Q13S-63.01_2022      						q6301
  Q13S-63A.01_2022     						q63A01
  Q13S-63AB.01_2022    						q63AB01
  Q13S-63B.01_2022     						q63B01
  Q13S-64.01_2022      						q6401
  Q13S-64.02_2022      						q6402
  Q13S-64.03_2022      						q6403
  Q13S-64.04_2022      						q6404
  CURDATE~D_2022       						intDay      
  CURDATE~M_2022       						intMo 
  CURDATE~Y_2022       						intYr 
  Q13-10_2022  	       		  			    q10				
;
data recip1;
 merge R30.lintdate2022 Q13 prg2022.oldin2022 (keep=norcid pydolo:);
 by norcid;
 if (intMo > 0);
recip = RECIP2;
data recip;
 set recip1;
 
* convert Y2K changes to simple years;
array yrs (*) intYr q43cy
              q44c01y q44c02y q44c03y q44c04y
              q45b01y q45b02y q45b03y q45b04y;
do i=1 to dim(yrs);
    if yrs(i) > 0 then yrs(i)=yrs(i)-1900;
end;
* date of this interview;
intDt=intYr*12+intMo;
/* ==========================================================================
  Merge info from several sources + convert weeks to months.
  ========================================================================== */
dummy = -4;
if q44c01y>-4 and q43cy>-4 and q44c01y<q43cy then do;
	q44c01y=q43cy;
	q44c01m=q43cm;
end;
else if q44c01y>-4 and q43cy>-4 and q44c01y>q43cy then do;
	q44c01y=q44c01y;
	q44c01m=q44c01m;
end;
else if q44c01y>-4 and q43cy>-4 and q44c01y=q43cy then do;
	q44c01m = max(q44c01m, q43cm);
	q44c01y = max(q44c01y, q43cy);
end;
else if q44c01y<=-4 and q43cy>-4 then do;
	q44c01m = max(q44c01m, q43cm);
	q44c01y = max(q44c01y, q43cy);
end;
/* nrOfRMo - # of months x was received (used when start/stop dates are not known).*/
array nrOfRMos  (*) q63a01 dummy dummy dummy;
nrOfRMos(1) = max(nrOfRMos(1), q63aa01, q63ab01);
do s = 1 to dim(nrOfRMos);
    if nrOfRMos(s) > 0 then
        nrOfRMos(s) = max(round(nrOfRMos(s)/4.3),1);
end;
* How much did R get during each month (by spells);
array howMuch (*) q47e01-q47e04;  
array q63b    (*) q63b01-q63b04;  
array q63    (*) q6301-q6304;     
do s=1 to dim(howMuch);
    if howMuch(s) = -4 then howMuch(s) = q63b(s);  
    if howMuch(s) > 0 then howMuch(s)=round(howMuch(s)*4.3,1); 
end;
/* ==========================================================================
   Recipiency status (rec) and amounts (dol) by months
   All months from 1978jan till dec of current year, indexed from 1900jan.
   78*12+1 = 937
   ========================================================================== */
array rec (937:&cEndMo);      * Did they receive x in that month?;
array dol (937:&cEndMo);      * How much?;
/* ========================================================================== 
 * No/unknown recipiency
 * ========================================================================== */
if recip=0 or q10=0 then do;
    do m=lint to intDt;
        rec(m)=-4;
        dol(m)=-4;
    end;
end;
else if recip in (-1,-2) then do;
    do m=lint to intDt;
        rec(m) = recip;
        dol(m) = recip;
    end;
end;
else if recip=-3 then
    do m=lint to intDt;
        rec(m) = -3;
        dol(m) = -3;
    end;
    
/* ========================================================================== 
 * There was some recipiency, get details
 * ========================================================================== */
else do;
check = 0;	
array startMo (*) q44c01m q44c02m q44c03m q44c04m;
array startYr (*) q44c01y q44c02y q44c03y q44c04y;
array endMo (*) q45b01m q45b02m q45b03m q45b04m;
array endYr (*) q45b01y q45b02y q45b03y q45b04y;
array cont    (*) q44d01-q44d04; 
array q44b    (*) q44b01-q44b04; 
array q64     (*) q6401-q6404;  
/* -----------------------------------------------------------------------------
 * Calculate starts and ends of spells if possible
 * -----------------------------------------------------------------------------*/
array starts (*) starts1-starts4;   
array ends   (*) ends1-ends4;    
 
* Continuous recipiency "ends" at interview date;
do s = 1 to dim(cont);
    if cont(s) = 1 then do;
        endYr(s) = intYr;
        endMo(s) = intMo;
    end;
end;
* Compute starts/stops/last for basic cases (dates are known);
do s = 1 to dim(starts);
    if startMo(s) > 0 & startYr(s) > 0 then
        starts(s) = startYr(s)*12+startMo(s);
    if endMo(s) > 0 & endYr(s) > 0 then
        ends(s) = endYr(s)*12+endMo(s);
end;
seamFlag=0;
do s = 1 to dim(starts);
	if starts(s) > 0 then do;
        if starts(s)=lint   then seamFlag=1; 
        if starts(s)=lint-1 then seamFlag=2; 
		if 0<starts(s)<lint-1 then seamFlag=3;
	end;
end;
lint_real=lint-936-1;
do s=1 to dim(starts);
 if starts(s) > 0 & starts(s)<lint then starts(s)=lint;
end;
* Try to deduce starts/ends from # of mos;
do s = 1 to dim(starts);
    if nrOfRMos(s) > 0 then do; 
       if ends(s) > 0 then do;
            starts(s) = ends(s) - nrOfRMos(s)+1;
			check=5.1;  
            if (starts(s) < lint) then check = 5;   
        end;
        else if starts(s) > 0 then do;
            ends(s) = starts(s) + nrOfRMos(s) - 1;
			check=100+s+0.1; 
			if ends(s)>intDt then check=100+s; 
        end;
		else if starts(s) = .  & ends(s) = .  then do; 
            if s = 1 then do; starts(s) = lint; check=201+0.1; end;   
			else do; starts(s) = ends(s-1) + 1; check=200+s+0.1; end; 
            ends(s) = starts(s) + nrOfRMos(s) - 1;
			if ends(s)>intDt then check=200+s;   
        end;
    end;
end;
last = 0;
if q44b01=2 or q43B = 2 then last = 1; 
do s = 1 to dim(starts);
    if ((startMo(s) > 0 | startYr(s) > 0 | endMo(s) > 0 | endYr(s) > 0 |nrOfRMos (s) > 0) & last < s) then last = s;
end;
/* -----------------------------------------------------------------------------
 * Edges of recipiency spells and periods between: n1 r1 n2 r2 ...  (NNNRRR???NRRR)
 * Under ideal conditions they touch, but often there is an unclear zone between them (-2)
 * ----------------------------------------------------------------------------- */
array rs(*) rs1-rs4;        * Recipiency starts;
array re(*) re1-re4;        * Recipiency ends;
array ns(*) ns1-ns5;        * Nonrecipiency starts (# of spells + 1, potentialy bef and after);
array ne(*) ne1-ne5;        * Nonrecipiency ends;
* The fully known cases;
do s = 1 to last;
    if starts(s) > 0 then do;
        ne(s) = starts(s)-1;
        rs(s) = starts(s);
    end;
    if ends(s) > 0 then do;
        re(s)   = ends(s);
        ns(s+1) = ends(s)+1;
    end;
end;
* The unknown and partially known cases;
do s = 1 to last;
    if starts(s) = . & startYr(s) > 0 then do; 
		check=301;  
        xne = startYr(s)*12;    
        if ( s = 1 & lint < =xne ) |
           ( s > 1 & 0 < ends(s-1) < xne) |
           ( s > 1 & 0 < endYr(s-1) + 1 < startYr(s) )
            then do; ne(s) = xne; check=302; end;  
        if startYr(s) < endYr(s) then do;
            rs(s) = startYr(s)*12+12;   
			check=303;   
		end;
    end;
    
    if (ends(s) = . & endYr(s) > 0) then do; 
		check=401; 
        if 0 < startYr(s) < endYr(s) then do;
            re(s) = endYr(s)*12+1;      
            ns(s+1) = endYr(s)*12+13;   
			check=402; 
		end;
		if 0 < startYr(s) = endYr(s) then do; 
          ns(s+1)=endYr(s)*12+13;		
		  if rs(s)>0 then do;
			re(s)=rs(s);
		  end;
		  check=403;
		end;
    end;
end;
if (ne(1) > 0) then ns(1) = lint;               * There was a nonrecipiency at the begining;
if (ns(last+1) > 0) then ne(last+1) = intDt;    * There was a nonrecipiency at the end;
if last>=2 then do s = 2 to last; 
	if 0 < rs(s) & rs(s) = re(s-1) then check = 7;
end;
  if rs1 > 0 & rs1<lint then rs1=lint;
  
/* -----------------------------------------------------------------------------
 * Fill the recipiency status (rec) and amounts (dol).
 * ----------------------------------------------------------------------------- */
* First, assume we know nothing;
do m = lint to intDt;
    rec(m) = -2;
    dol(m) = -2;
end;
* Fill in info we know (any of the periods below can be empty);
do s = 1 to last;
    * nonrecipiency period;
    if (0 < ns(s) <= ne(s)) then
        do m = max(ns(s),lint) to min(ne(s),intDt);
            rec(m) = -4;
            dol(m) = -4;
        end;
    * recipiency period;
    if (0 < rs(s) <= re(s)) then
        do m = max(rs(s),lint) to min(re(s),intDt);
            rec(m) = 1;
            dol(m) = howMuch(s);
			if howmuch(s) in (. -4) then do; dol(m)=-2; check5=s+0.1; end; 
        end;
    * we know only start - we are sure R received smth that month;
    else if (lint <= rs(s) <= intDt & re(s) = .) then do;       
        rec(rs(s)) = 1;
        dol(rs(s)) = howMuch(s);
        if howmuch(s) in (. -4) then do; dol(rs(s))=-2; check5=s+0.2; end;
    end;
    * we know only end - we are sure R received smth that month (can be even intDt if continuous);
    else if (rs(s) = . & lint <= re(s) <= intDt) then do;
        rec(re(s)) = 1;
        dol(re(s)) = howMuch(s);
		if howmuch(s) in (. -4) then do; dol(re(s))=-2; check5=s+0.3; end;
    end;
end;
* The last period of nonrecipiency;
if (0 < ns(last+1) <= ne(last+1)) then
    do m = ns(last+1) to min(ne(last+1),intDt);
        rec(m) = -4;
        dol(m) = -4;
    end;
end;
/* ========================================================================== */
/* End if recip = .... (getting details for people who got something)
/* ========================================================================== */
* Fill in space after the interview;
do m=intDt+1 to hbound(rec);
    rec(m)=-4;
    dol(m)=-4;
end;
endDt=intDt-936;
noInt=0;
if q44c01m in (-1,-2) & q44c01y in (-1,-2) then q43b = 2;
if noInt=0 then
    do i=lbound(rec) to hbound(rec);
        if rec(i)=. then rec(i)=-4;
        if dol(i)=. then dol(i)=-4;
    end;
if noInt=1 then
    do i=lbound(rec) to hbound(rec);
        if rec(i)=. then rec(i)=-5;
        if dol(i)=. then dol(i)=-5;
    end;
    
/* ==========================================================================
 * Calculating yearly variables.
 * ========================================================================== */
array recYM(&cYrs,12) rec1-rec&cMos;
array dolYM(&cYrs,12) dol1-dol&cMos;
array yRec(*)   yRec78-yRec&cEndYr;
array yDol(*)   yDol78-yDol&cEndYr;
array yRecMo(*) yRecMo78-yRecMo&cEndYr;
* Calculate yRec (any recipiency in a yr?);
do y=1 to dim(yRec);
    do m=1 to 12;
        if recYM(y,m) ~= . then    yRec(y)=0;
        if recYM(y,m) > 0 then do; yRec(y)=1; leave; end;
    end;
	if yRec(y)=0 then do m=1 to 12;
	    if recYM(y,m) in (-1 -2 -3) then do;  yRec(y)=recYM(y,m); leave; end;
	end;
	if yRec(y)=0 then yRec(y)=-4;	
end;
* Calculate yDol ($ in yr), yRecMo (# of months of recipiency in each y);
do y=1 to dim(yRec);
    if yRec(y) > 0 then do;	
		rrefuse = 0; drefuse = 0;
		rdk = 0;     ddk = 0;
        do m=1 to 12;
			if dolYM(y,m) = -1 then drefuse = 1;
			else if dolYM(y,m) = -2 then ddk = 1;
            if recYM(y,m) = -1 then rrefuse = 1;
			else if recYM(y,m) = -2 then rdk = 1;
		end;
		if rrefuse = 1 then yRecMo(y) = -1;
		else if rdk = 1 then yRecMo(y) = -2;
		else do;
	        yRecMo(y) = 0;
	        do m=1 to 12;
	            if recYM(y,m) = 1 then yRecMo(y)=yRecMo(y)+1;
	        end;
	    end;				
	    if rrefuse = 1 or drefuse = 1 then yDol(y) = -1;
		else if rdk = 1 or ddk = 1 then yDol(y) = -2;
		else do;
	        yDol(y) = 0;
	        do m=1 to 12;
	            if 0 <= dolYM(y,m) then yDol(y)=yDol(y)+dolYM(y,m); 
	        end;
	    end;
	end;
	else do;
		yDol(y)=yRec(y);
		yRecMo(y)=yRec(y); 
	end;
end;
/* ==========================================================================
 *  Flag yearly amount that are not within possible bounds.
 * ========================================================================== */
array yFlg(*)   yFlg78-yFlg&cEndYr;   
array cMinDol (&cYrs) _temporary_
    (36 40 43 48 50 49 51 54 56 58 61 65 68 70 70 72 74 29*76);
array cMaxDol (&cYrs) _temporary_
    (158 173 187 208 217 215 222 236 245 254 266 284 298 305 305 315 322 333 333 383 383 425 425 7*471 3*525 550 575 11*653);
    
do y=1 to dim(yRec);
    yFlg(y) = 0;    
    if yRec(y) = -5 then yFlg(y)=-5;
    if yDol(y) < 0 then continue; 
	avgDol = yDol(y) / yRecMo(y);
    if avgDol < cMinDol(y)*4.3 then
		yFlg(y)=1;
	else if cMaxDol(y)*4.3 < avgDol then do;
        yFlg(y)=2;
		if cMinDol(y)*4.3 <= avgDol / yRecMo(y) <= cMaxDol(y)*4.3 then yFlg(y)=3;
    end;
end;
/* ==========================================================================
 *   DOL yearly amount
 * ========================================================================== */
do y=1 to dim(yRec);
    if yDol(y) = .  then yDol(y)=-4;
    if yRec(y) = -4 then yRec(y)=0;
end;
yflag=0;
array ydolo(*)   pyDolo78-pyDolo&cEndYr;
do i=1 to dim(ydol);
 if lintyr=i+77 & 0<lintmo<13 then do;
  if ydol(i)=-4 then do; ydol(i)=ydolo(i); yflag=1; end;
  else if ydol(i)>=0 & ydolo(i) not in (-4 0) then do;
    if ydolo(i)>0 then do; ydol(i)=ydol(i)+ydolo(i); yflag=2; end;
	else if ydolo(i) in (-1 -2 -3) then do; ydol(i)=ydolo(i); yflag=3; end;
  end;
 end;
end;

AFDC/TANF Receipt

%let cEndYr = 123;		*(2023-1900);
%let cEndMo = 1488;     *(123+1)*12;
%let cYrs = 46;			*(2023-1978)+1;
%let cMos = 552;		*46*12;
%let cFillFlag = 2022;
data Q13;
 set prg2022.in_inc_2022;
 
VARIABLE NAMES IN PUBLIC RELEASE		VARIABLE NAMES IN PROGRAM
  Q13RECIP-4~000001_2022					 	recip41                      
  Q13RECIP-4~000002_2022						recip42                      
  Q13RECIP-4~000003_2022						recip43                      
  Q13RECIP-4~000004_2022						recip44                      
  Q13A-BB_2022          						QBB          
  Q13A-43B_2022         						Q43B         
  Q13A-43C~M_2022       						Q43CM       
  Q13A-43C~Y_2022       						Q43CY       
  Q13A-44A1_CHK1.01_2022					    Q44A1_CHK11
  Q13A-44A3.01_2022     						Q44A301     
  Q13A-44A5.01_2022     						Q44A501     
  Q13A-44A6.01_2022     						Q44A601     
  Q13A-44B.01_2022      						Q44B01      
  Q13A-44D.01_2022      						Q44D01     
  Q13A-45A.01_2022      						Q45A01      
  Q13A-45B.01~M_2022    						Q45B01M    
  Q13A-45B.01~Y_2022    						Q45B01Y    
  Q13A-47E.01_2022      						Q47E01       
  Q13A-62.01_2022       						Q6201      
  Q13A-62A.01_2022      						Q62A01    
  Q13A-63A.01_2022      						Q63A01    
  Q13A-63AA.01_2022     						Q63AA01    
  Q13A-63B.01_2022      						Q63B01     
  Q13A-63C.01_2022      						Q63C01      
  Q13A-63D.01_2022      						Q63D01 
  Q13A-64.01_2022       						Q6401       
  Q13A-64A.01_2022      						Q64A01      
  CURDATE~D_2022        						intDay      
  CURDATE~M_2022        						intMo       
  CURDATE~Y_2022        						intYr;
        
data recip1;
 merge R30.lintdate2022 Q13 prg2022.oldin2022 (keep=norcid aydolo:);
 by norcid;
 if (intMo > 0);
 
recip = RECIP41;
*************************************************************************************************************;
data recip;
 set recip1;
 
* convert Y2K changes to simple years;
array yrs (*) intYr q43cy q45b01y; 
do i=1 to dim(yrs);
    if yrs(i) > 0 then yrs(i)=yrs(i)-1900;
end;
* date of this interview;
intDt=intYr*12+intMo;
/* ==========================================================================
  Merge info from several sources + convert weeks to months.
  ========================================================================== */
dummy = -4;    
if q44c01y>-4 and q43cy>-4 and q44c01y<q43cy then do;
	q44c01y=q43cy;
	q44c01m=q43cm;
end;
else if q44c01y>-4 and q43cy>-4 and q44c01y>q43cy then do;
	q44c01y=q44c01y;
	q44c01m=q44c01m;
end;
else if q44c01y>-4 and q43cy>-4 and q44c01y=q43cy then do;
	q44c01m = max(q44c01m, q43cm);
	q44c01y = max(q44c01y, q43cy);
end;
else if q44c01y<=-4 and q43cy>-4 then do;
	q44c01m = max(q44c01m, q43cm);
	q44c01y = max(q44c01y, q43cy);
end;
/* nrOfRMos - # of months x was received (used when start/stop dates are not known).*/
array nrOfRMos (*) q63aa01; 
nrOfRMos(1) = max(nrOfRMos(1), q63a01, q63ab01);
* How much did R receive in each spell;
array howMuch (*)  q47e01; 
array q63b    (*)  q63b01; 
do s=1 to dim(howMuch);
    if howMuch(s) = -4 then howMuch(s) = q63b(s); 
end;
/* ==========================================================================
   Recipiency status (rec) and amounts (dol) by months
   All months from 1978jan till dec of current year, indexed from 1900jan.
   78*12+1 = 937
   ========================================================================== */
array rec (937:&cEndMo);      * Did they receive x in that month?;
array dol (937:&cEndMo);      * How much?;
/* ========================================================================== 
 * No/unknown recipiency
 * ========================================================================== */
if recip=0 then do;
    do m=lint to intDt;
        rec(m)=-4;
        dol(m)=-4;
    end;
end;
else if recip in (-1,-2) then do;
    do m=lint to intDt;
        rec(m) = recip;
        dol(m) = recip;
    end;
end;
else if recip in (-3) then do;
    do m=lint to intDt;
        rec(m) = recip;
        dol(m) = recip;
    end;
end;
/* ========================================================================== */
/* There was some recipiency, get details */
/* ========================================================================== */
else do;
check = 0;	
array startMo (*) q44c01m;
array startYr (*) q44c01y 
array endMo (*) q45b01m; 
array endYr (*) q45b01y; 
array cont (*) q44d01;
array q44b (*) q44b01;
array q64  (*) q6401;
array q63c (*) q63c01; 
/* -----------------------------------------------------------------------------
 * Calculate starts and ends of spells if possible
 * -----------------------------------------------------------------------------*/
array starts (*) starts1;
array ends   (*) ends1; 
* Continuous recipiency "ends" at interview date;
do s = 1 to dim(cont);
	if cont(s) = 1 or q63c(s)=12 then do; 
		endYr(s) = intYr;
		endMo(s) = intMo;
	end;
end;
* Compute starts/stops/last for basic cases (dates are known);
do s = 1 to dim(starts);
    if startMo(s) > 0 & startYr(s) > 0 then
        starts(s) = startYr(s)*12+startMo(s);
    if endMo(s) > 0 & endYr(s) > 0 then
        ends(s) = endYr(s)*12+endMo(s);
end;
seamFlag=0;
do s = 1 to dim(starts);
	if starts(s) > 0 then do;
        if starts(s)=lint   then seamFlag=1; 
        if starts(s)=lint-1 then seamFlag=2; 
		if 0<starts(s)<lint-1 then seamFlag=3;
	end;
end;
lint_real=lint-936-1;
do s=1 to dim(starts);
 if starts(s) > 0 & starts(s)<lint then starts(s)=lint;
end;
* Try to deduce starts/ends from # of mos;
do s = 1 to dim(starts);
    if nrOfRMos(s) > 0 then do;  
	    if ends(s) > 0 & starts(s) = .  then do;         
            starts(s) = ends(s) - nrOfRMos(s)+1;
			check=5.1;  
            if (starts(s) < lint) then check = 5;  
        end;
		else if starts(s) > 0 & ends(s) = .  then do; 
            ends(s) = starts(s) + nrOfRMos(s) - 1;
			check=100+s+0.1; 
			if ends(s)>intDt then check=100+s; 
        end;
		else if starts(s) = .  & ends(s) = .  then do; 
            if s = 1 then do; starts(s) = lint; check=201+0.1; end;  
			else do; starts(s) = ends(s-1) + 1; check=200+s+0.1; end; 
            ends(s) = starts(s) + nrOfRMos(s) - 1;
			if ends(s)>intDt then check=200+s;  
        end;
    end;
end;
/* Determine what was the last spell (0 - there was no spell) */
last = 0;
if q44b01=2 or q43B = 2 then last = 1; 
do s = 1 to dim(starts);
	if ((startMo(s) > 0 | startYr(s) > 0 | endMo(s) > 0 | endYr(s) > 0 |nrOfRMos (s) > 0) & last < s) then last = s;
end;
/* -----------------------------------------------------------------------------
 * Edges of recipiency spells and periods between: n1 r1 n2 r2 ...  (NNNRRR???NRRR)
 * Under ideal conditions they touch, but often there is an unclear zone between them (-2)
 * ----------------------------------------------------------------------------- */
array rs(*) rs1;      		* Recipiency starts;
array re(*) re1;      		* Recipiency ends;
array ns(*) ns1-ns2;		* Nonrecipiency starts (# of spells + 1, potentialy bef and after);
array ne(*) ne1-ne2;		* Nonrecipiency ends;
* The fully known cases;
do s = 1 to last;
    if starts(s) > 0 then do;
        ne(s) = starts(s)-1;
        rs(s) = starts(s);
    end;
    if ends(s) > 0 then do;
        re(s)   = ends(s);
        ns(s+1) = ends(s)+1;
    end;
end;
* The unknown and partially known cases;
do s = 1 to last;
    if starts(s) = . & startYr(s) > 0 then do; 
		check=301; 
        xne = startYr(s)*12;  
        if ( s = 1 & lint <= xne ) |
           ( s > 1 & 0 < ends(s-1) < xne) |
           ( s > 1 & 0 < endYr(s-1) + 1 < startYr(s) )
            then do; ne(s) = xne; check=302; end; 
        if startYr(s) < endYr(s) then do;
            rs(s) = startYr(s)*12+12;     
			check=303;     
		end;
    end;
    
    if (ends(s) = . & endYr(s) > 0) then do; 
		check=401;
        if 0 < startYr(s) < endYr(s) then do;
            re(s) = endYr(s)*12+1;      
            ns(s+1) = endYr(s)*12+13;   
			check=402; 
		end;
		if 0 < startYr(s) = endYr(s) then do; 
		  ns(s+1)=endYr(s)*12+13; 
		  if rs(s)>0 then do;
			re(s)=rs(s);
		  end;
		  check=403;
		end;
    end;
end;
if (ne(1) > 0) then ns(1) = lint;				* There was a nonrecipiency at the begining;
if (ns(last+1) > 0) then ne(last+1) = intDt;	* There was a nonrecipiency at the end;
if last>=2 then do s = 2 to last;
	if 0 < rs(s) & rs(s) = re(s-1) then check = 7;
end;
 if rs1 > 0 & rs1<lint then rs1=lint;
 
/* -----------------------------------------------------------------------------
 * Fill the recipiency status (rec) and amounts (dol).
 * ----------------------------------------------------------------------------- */
* First, assume we know nothing;
do m = lint to intDt;
	rec(m) = -2;
	dol(m) = -2;
end;
* Fill in info we know (any of the periods below can be empty);
do s = 1 to last;
	* nonrecipiency period;
	if (0 < ns(s) <= ne(s)) then
		do m = max(ns(s),lint) to min(ne(s),intDt);
			rec(m) = -4;
			dol(m) = -4;
		end;
	* recipiency period;
	if (0 < rs(s) <= re(s)) then
		do m = max(rs(s),lint) to min(re(s),intDt); 
			rec(m) = 1;
			dol(m) = howMuch(s);
			if howmuch(s) in (. -4) then do; dol(m)=-2; check5=s+0.1; end; 
		end;
	    * we know only start - we are sure R received smth that month;
        else if (lint <= rs(s) <= intDt & re(s) = .) then do;     
            rec(rs(s)) = 1;
            dol(rs(s)) = howMuch(s);
		if howmuch(s) in (. -4) then do;  dol(rs(s))=-2; check5=s+0.2; end; 
        end;
        * we know only end - we are sure R received smth that month (can be even intDt if continuous);
        else if (rs(s) = . & lint <= re(s) <= intDt) then do;
            rec(re(s)) = 1;
            dol(re(s)) = howMuch(s);
		if howmuch(s) in (. -4) then do; dol(re(s))=-2; check5=s+0.3; end; 
        end;
end;
* The last period of nonrecipiency;
if (0 < ns(last+1) <= ne(last+1)) then
	do m = ns(last+1) to min(ne(last+1),intDt);
		rec(m) = -4;
		dol(m) = -4;
	end;
end;
/* ========================================================================== */
/* End if recip = .... (getting details for people who got something)
/* ========================================================================== */
* Fill in space at the end of year after the interview;
do m=intDt+1 to hbound(rec);
    rec(m)=-4;
    dol(m)=-4;
end;
endDt=intDt-936;
noInt=0;
if q44c01m in (-1,-2) & q44c01y in (-1,-2) then q43b = 2;
/* ========================================================================== */
array flag(937:&cEndMo) flag1-flag&cMos;
array recYM(&cYrs,12) rec1-rec&cMos;
array dolYM(&cYrs,12) dol1-dol&cMos;
* Set fill flag for ints/non-ints;
if noInt in (0,1) then
	do i=lint to intDt;
		flag(i)=&cFillFlag;
	end;
	
/* ==========================================================================
 * fill in missings: -4 if int, -5 if non-int
 * ========================================================================== */
if noInt=0 then
	do i=lbound(rec) to hbound(rec);
 		if rec(i)=. then rec(i)=-4;
 		if dol(i)=. then dol(i)=-4;
 		if flag(i)=. then flag(i)=-4;
 	end;
if noInt=1 then
	do i=lbound(rec) to hbound(rec);
 		if rec(i)=. then rec(i)=-5;
 		if dol(i)=. then dol(i)=-5;
 		if flag(i)=. then flag(i)=-4;
 	end;
 	
/* ==========================================================================
 * Calculating yearly variables.
 * ========================================================================== */
array yRec(*)   yRec78-yRec&cEndYr;
array yDol(*)   yDol78-yDol&cEndYr;
array yRecMo(*) yRecMo78-yRecMo&cEndYr;
* Calculate yRec (any recipiency in a yr?);
do y=1 to dim(yRec);
    do m=1 to 12;
        if recYM(y,m) ~= . then    yRec(y)=0;
        if recYM(y,m) > 0 then do; yRec(y)=1; leave; end;
    end;
	if yRec(y)=0 then do m=1 to 12;
	    if recYM(y,m) in (-1 -2 -3) then do;  yRec(y)=recYM(y,m); leave; end;
	end;
	if yRec(y)=0 then yRec(y)=-4; 
end;
* Calculate yDol ($ in yr), yRecMo (# of months of recipiency in each y);
do y=1 to dim(yRec);
    if yRec(y) > 0 then do;
		rrefuse = 0; drefuse = 0;
		rdk = 0;     ddk = 0;
        do m=1 to 12;
			if dolYM(y,m) = -1 then drefuse = 1;
			else if dolYM(y,m) = -2 then ddk = 1;
            if recYM(y,m) = -1 then rrefuse = 1;
			else if recYM(y,m) = -2 then rdk = 1;
		end;
		if rrefuse = 1 then yRecMo(y) = -1;
		else if rdk = 1 then yRecMo(y) = -2;
		else do; 
	        yRecMo(y) = 0;
	        do m=1 to 12;
	            if recYM(y,m) = 1 then yRecMo(y)=yRecMo(y)+1;
	        end;
	    end;		
	    if rrefuse = 1 or drefuse = 1 then yDol(y) = -1;
		else if rdk = 1 or ddk = 1 then yDol(y) = -2;
		else do;
	        yDol(y) = 0;
	        do m=1 to 12;
	            if 0 <= dolYM(y,m) then yDol(y)=yDol(y)+dolYM(y,m); 
	        end;
	    end;
	end;
	else do;
		yDol(y)=yRec(y);
		yRecMo(y)=yRec(y); 
	end;
end;
/* ==========================================================================
 *  Flag yearly amount that are not within possible bounds.
 * ========================================================================== */
 
array yFlg(*)   yFlg78-yFlg&cEndYr;   
array cMinDol (&cYrs) _temporary_ (&cYrs*46);
array cMaxDol (&cYrs) _temporary_
	(537 579 586 622 643 670 700 726 742 771 794 815 809 786 875 844 827 808 808
	949 949 1025 1025 1134 1134 21*1134);
	
do y=1 to dim(yRec);
    yFlg(y) = 0;  
    if yRec(y) = -5 then yFlg(y)=-5;
    if yDol(y) < 0 then continue;   
	avgDol = yDol(y) / yRecMo(y);
    if avgDol < cMinDol(y) then
		yFlg(y)=1;
	else if cMaxDol(y) < avgDol then do;
        yFlg(y)=2;
        if cMinDol(y) <= avgDol / yRecMo(y) <= cMaxDol(y) then yFlg(y)=3;
    end;
end;
/* ==========================================================================
 *   DOL yearly amount
 * ========================================================================== */
do y=1 to dim(yRec);
    if yDol(y) = .  then yDol(y)=-4;
    if yRec(y) = -4 then yRec(y)=0;
end;
yflag=0;
array ydolo(*)   ayDolo78-ayDolo&cEndYr;
do i=1 to dim(ydol);
 if lintyr=i+77 & 0<lintmo<13 then do;
  if ydol(i)=-4 then do; ydol(i)=ydolo(i); yflag=1; end;
  else if ydol(i)>=0 & ydolo(i) not in (-4 0) then do;
    if ydolo(i)>0 then do; ydol(i)=ydol(i)+ydolo(i); yflag=2; end;
	else if ydolo(i) in (-1 -2 -3) then do; ydol(i)=ydolo(i); yflag=3; end;
  end;
 end;
end;

Food Stamps/SNAP Receipt

%let cEndYr = 123;		*(2023-1900);
%let cEndMo = 1488;     *(123+1)*12;
%let cYrs = 46;			*(2023-1978)+1;
%let cMos = 552;		*46*12;
%let cFillFlag = 2022;
data Q13;
 set prg2022.in_inc_2022;
 
VARIABLE NAMES IN PUBLIC RELEASE		VARIABLE NAMES IN PROGRAM
Q13RECIP-4~000001_2022 					RECIP41                    
Q13RECIP-4~000002_2022 					RECIP42                    
Q13RECIP-4~000003_2022 					RECIP43                    
Q13RECIP-4~000004_2022 					RECIP44                    
Q13RECIP-4B_2022       					RECIP4B                          
Q13F-B_2022            					qB                                    
Q13F-43B_2022          					q43B                                
Q13F-43C~M_2022        					q43CM                             
Q13F-43C~Y_2022        					q43CY                             
Q13F-44A1_CHK1.01_2022 					q44A1CHK101                
Q13F-44A1_CHK1.02_2022 					q44A1CHK102                
Q13F-44A3.01_2022      					q44A301                         
Q13F-44A3.02_2022      					q44A302                         
Q13F-44A5.01_2022      					q44A501                         
Q13F-44A6.01_2022      					q44A601                         
Q13F-44B.01_2022       					q44B01                           
Q13F-44B.02_2022       					q44B02                           
Q13F-44C.01~M_2022     					q44C01M                        
Q13F-44C.01~Y_2022     					q44C01Y                        
Q13F-44C.02~M_2022     					q44C02M                        
Q13F-44C.02~Y_2022     					q44C02Y                        
Q13F-44D.01_2022       					q44D01                           
Q13F-44D.02_2022       					q44D02                           
Q13F-45A.01_2022       					q45A01                           
Q13F-45A.02_2022       					q45A02                           
Q13F-45B.01~M_2022     					q45B01M                        
Q13F-45B.01~Y_2022     					q45B01Y                        
Q13F-45B.02~M_2022     					q45B02M                        
Q13F-45B.02~Y_2022     					q45B02Y                        
Q13F-47E.01_2022       					q47E01                           
Q13F-47E.02_2022       					q47E02                           
Q13F-62.01_2022        					q6201                             
Q13F-62.02_2022        					q6202                             
Q13F-62A.01_2022       					q62A01                           
Q13F-62A.02_2022       					q62A02                           
Q13F-63.01_2022        					q6301                             
Q13F-63A.01_2022       					q63A01                           
Q13F-63AA.01_2022      					q63AA01                         
Q13F-63AB.01_2022      					q63AB01                         
Q13F-63AB.02_2022      					q63AB02                         
Q13F-63B.01_2022       					q63B01                           
Q13F-63B.02_2022       					q63B02                           
Q13F-63C.01_2022       					q63C01                           
Q13F-63C.02_2022       					q63C02                           
Q13F-63D.01_2022       					q63D01                           
Q13F-63D.02_2022       					q63D02                           
Q13F-64.01_2022        					q6401
Q13F-64.02_2022        					q6402
Q13F-64A.01_2022       					q64A01
Q13F-64A.02_2022       					q64A02
CURDATE~D_2022         					intDay 
CURDATE~M_2022         					intMo
CURDATE~Y_2022         					intYr 
;          
       
data recip1;
 merge R30.lintdate2022 Q13 prg2022.oldin2022 (keep=norcid fydolo:);
 by norcid;
 if (intMo > 0); 
recip = RECIP42;
                      
data recip;
 set recip1;
 
* convert Y2K changes to simple years;
array yrs (*) intYr q43cy
              q44c01y q44c02y
              q45b01y q45b02y;
do i=1 to dim(yrs);
    if yrs(i) > 0 then yrs(i)=yrs(i)-1900;
end;
* date of this interview;
intDt=intYr*12+intMo;
/* ==========================================================================
  Merge info from several sources + convert weeks to months.
  ========================================================================== */
dummy = -4; 
if q44c01y>-4 and q43cy>-4 and q44c01y<q43cy then do;
	q44c01y=q43cy;
	q44c01m=q43cm;
end;
else if q44c01y>-4 and q43cy>-4 and q44c01y>q43cy then do;
	q44c01y=q44c01y;
	q44c01m=q44c01m;
end;
else if q44c01y>-4 and q43cy>-4 and q44c01y=q43cy then do;
	q44c01m = max(q44c01m, q43cm);
	q44c01y = max(q44c01y, q43cy);
end;
else if q44c01y<=-4 and q43cy>-4 then do;
	q44c01m = max(q44c01m, q43cm);
	q44c01y = max(q44c01y, q43cy);
end;
/* nrOfRMos - # of months x was received (used when start/stop dates are not known).*/
array nrOfRMos  (*) q63ab01 q63ab02;
nrOfRMos(1) = max(nrOfRMos(1), q63a01, q63aa01);
* How much did R receive in each spell ;
array howMuch (*) q47e01-q47e02;  
array q63b    (*) q63b01-q63b02;  
do s=1 to dim(howMuch);
    if howMuch(s) = -4 then howMuch(s) = q63b(s);  
end;
/* ==========================================================================
   Recipiency status (rec) and amounts (dol) by months
   All months from 1978jan till dec of current year, indexed from 1900jan.
   78*12+1 = 937
   ========================================================================== */
array rec (937:&cEndMo);      * Did they receive x in that month?;
array dol (937:&cEndMo);      * How much?;
/* ========================================================================== 
 * No/unknown recipiency
 * ========================================================================== */
if recip=0 then do;
    do m=lint to intDt;
        rec(m)=-4;
        dol(m)=-4;
    end;
end;
else if recip in (-1,-2) then do;
    do m=lint to intDt;
        rec(m) = recip;
        dol(m) = recip;
    end;
end;
else if recip in (-3) then do;
    do m=lint to intDt;
        rec(m) = recip;
        dol(m) = recip;
    end;
end;
/* ==========================================================================
 * There was some recipiency, get details
 * ========================================================================== */
else do;
check = 0;	
array startMo (*) q44c01m q44c02m; 
array startYr (*) q44c01y q44c02y; 
array endMo (*) q45b01m q45b02m;
array endYr (*) q45b01y q45b02y;
array cont   (*) q44d01-q44d02; 
array q44b (*) q44b01 q44b02;
array q64  (*) q6401 Q6402;   
array q63c    (*) q63c01 Q63c02;
/* -----------------------------------------------------------------------------
 * Calculate starts and ends of spells if possible
 * -----------------------------------------------------------------------------*/
array starts (*) starts1-starts2; 
array ends   (*) ends1-ends2;     
* Continuous recipiency "ends" at interview date;
do s = 1 to dim(cont);
	if cont(s) = 1 or q63c(s)=9 then do; 
        endYr(s) = intYr;	
        endMo(s) = intMo;
    end;
end;
* Compute starts/stops/last for basic cases (dates are known);
do s = 1 to dim(starts);
    if startMo(s) > 0 & startYr(s) > 0 then
        starts(s) = startYr(s)*12+startMo(s);
    if endMo(s) > 0 & endYr(s) > 0 then
        ends(s) = endYr(s)*12+endMo(s);
end;
seamFlag=0;
do s = 1 to dim(starts);
	if starts(s) > 0 then do;
        if starts(s)=lint   then seamFlag=1; 
        if starts(s)=lint-1 then seamFlag=2; 
		if 0<starts(s)<lint-1 then seamFlag=3;
	end;
end;
lint_real=lint-936-1;
do s=1 to dim(starts);
  if starts(s) > 0 & starts(s)<lint then starts(s)=lint;
end;
* Try to deduce starts/ends from # of mos;
do s = 1 to dim(starts);
    if nrOfRMos(s) > 0 then do;
	    if ends(s) > 0 & starts(s) = .  then do;         
            starts(s) = ends(s) - nrOfRMos(s)+1;
			check=5.1;  
            if (starts(s) < lint) then check = 5;  
        end;
		else if starts(s) > 0 & ends(s) = .  then do;
            ends(s) = starts(s) + nrOfRMos(s) - 1;
			check=100+s+0.1; 
			if ends(s)>intDt then check=100+s;
        end;
		else if starts(s) = .  & ends(s) = .  then do; 
            if s = 1 then do; starts(s) = lint; check=201+0.1; end;   
			else do; starts(s) = ends(s-1) + 1; check=200+s+0.1; end; 
            ends(s) = starts(s) + nrOfRMos(s) - 1;
			if ends(s)>intDt then check=200+s; 
        end;
    end;
end;
/* Determine what was the last spell (0 - there was no spell)*/
last = 0;
if q44b01=2 or q43B = 2 then last = 1; 
do s = 1 to dim(starts);
    if ((startMo(s) > 0 | startYr(s) > 0 | endMo(s) > 0 | endYr(s) > 0 |nrOfRMos (s) > 0) & last < s) then last = s;
end;
/* -----------------------------------------------------------------------------
 * Edges of recipiency spells and periods between: n1 r1 n2 r2 ...  (NNNRRR???NRRR)
 * Under ideal conditions they touch, but often there is an unclear zone between them (-2)
 * ----------------------------------------------------------------------------- */
array rs(*) rs1-rs2;        * Recipiency starts;
array re(*) re1-re2;        * Recipiency ends;
array ns(*) ns1-ns3;        * Nonrecipiency starts (# of spells + 1, potentialy bef and after);
array ne(*) ne1-ne3;        * Nonrecipiency ends;
* The fully known cases;
do s = 1 to last;
    if starts(s) > 0 then do;
        ne(s) = starts(s)-1;
        rs(s) = starts(s);
    end;
    if ends(s) > 0 then do;
        re(s)   = ends(s);
        ns(s+1) = ends(s)+1;
    end;
end;
* The unknown and partially known cases;
do s = 1 to last;
    if starts(s) = . & startYr(s) > 0 then do;
		check=301;  
        xne = startYr(s)*12;  
        if ( s = 1 & lint <= xne ) |
           ( s > 1 & 0 < ends(s-1) < xne) |
           ( s > 1 & 0 < endYr(s-1) + 1 < startYr(s) )
            then do; ne(s) = xne; check=302; end;  
        if startYr(s) < endYr(s) then do;
            rs(s) = startYr(s)*12+12;  
			check=303;  
		end;
    end;
    if (ends(s) = . & endYr(s) > 0) then do; 
		check=401; 
        if 0 < startYr(s) < endYr(s) then do;
            re(s) = endYr(s)*12+1;   
            ns(s+1) = endYr(s)*12+13;
			check=402;
		end;
		if 0 < startYr(s) = endYr(s) then do; 
		  ns(s+1)=endYr(s)*12+13;
		  if rs(s)>0 then do;
			re(s)=rs(s);
		  end;
		  check=403;
		end;
    end;
end;
if (ne(1) > 0) then ns(1) = lint;               * There was a nonrecipiency at the begining;
if (ns(last+1) > 0) then ne(last+1) = intDt;    * There was a nonrecipiency at the end;
if last>=2 then do s = 2 to last; 
	if 0 < rs(s) & rs(s) = re(s-1) then check = 7;
end;
 if rs1 > 0 & rs1<lint then rs1=lint;
 
/* -----------------------------------------------------------------------------
 * Fill the recipiency status (rec) and amounts (dol).
 * ----------------------------------------------------------------------------- */
* First, assume we know nothing;
do m = lint to intDt;
    rec(m) = -2;
    dol(m) = -2;
end;
* Fill in info we know (any of the periods below can be empty);
do s = 1 to last;
    * nonrecipiency period;
    if (0 < ns(s) <= ne(s)) then
        do m = max(ns(s),lint) to min(ne(s),intDt);
            rec(m) = -4;
            dol(m) = -4;
        end;
    * recipiency period;
    if (0 < rs(s) <= re(s)) then
        do m = max(rs(s),lint) to min(re(s),intDt); 
            rec(m) = 1;
            dol(m) = howMuch(s);
			if howmuch(s) in (. -4) then do; dol(m)=-2; check5=s+0.1; end; 
        end;
    * we know only start - we are sure R received smth that month;
    else if (lint <= rs(s) <= intDt & re(s) = .) then do;  
        rec(rs(s)) = 1;
        dol(rs(s)) = howMuch(s);
        if howmuch(s) in (. -4) then do; dol(rs(s))=-2; check5=s+0.2; end; 
    end;
    * we know only end - we are sure R received smth that month (can be even intDt if continuous);
    else if (rs(s) = . & lint <= re(s) <= intDt) then do;
        rec(re(s)) = 1;
        dol(re(s)) = howMuch(s);
		if howmuch(s) in (. -4) then do;  dol(re(s))=-2; check5=s+0.3; end; 
    end;
end;
* The last period of nonrecipiency;
if (0 < ns(last+1) <= ne(last+1)) then
    do m = ns(last+1) to min(ne(last+1),intDt);
        rec(m) = -4;
        dol(m) = -4;
    end;
end;
/* ========================================================================== */
/* End if recip = .... (getting details for people who got something)
/* ========================================================================== */
* Fill in space at the end of year after the interview;
do m=intDt+1 to hbound(rec);
    rec(m)=-4;
    dol(m)=-4;
end;
endDt=intDt-936;
noInt=0;
if q44c01m in (-1,-2) & q44c01y in (-1,-2) then q43b = 2;
if noInt=0 then
    do i=lbound(rec) to hbound(rec);
        if rec(i)=. then rec(i)=-4;
        if dol(i)=. then dol(i)=-4;
    end;
if noInt=1 then
    do i=lbound(rec) to hbound(rec);
        if rec(i)=. then rec(i)=-5;
        if dol(i)=. then dol(i)=-5;
    end;
    
/* ==========================================================================
 * Calculating yearly variables.
 * ========================================================================== */
array recYM(&cYrs,12) rec1-rec&cMos;
array dolYM(&cYrs,12) dol1-dol&cMos;
array yRec(*)   yRec78-yRec&cEndYr;
array yDol(*)   yDol78-yDol&cEndYr;
array yRecMo(*) yRecMo78-yRecMo&cEndYr;
* Calculate yRec (any recipiency in a yr?);
do y=1 to dim(yRec);
    do m=1 to 12;
        if recYM(y,m) ~= . then    yRec(y)=0;
        if recYM(y,m) > 0 then do; yRec(y)=1; leave; end;
    end;
	if yRec(y)=0 then do m=1 to 12;
	    if recYM(y,m) in (-1 -2 -3) then do;  yRec(y)=recYM(y,m); leave; end;
	end;
	if yRec(y)=0 then yRec(y)=-4;
end;
* Calculate yDol ($ in yr), yRecMo (# of months of recipiency in each y);
do y=1 to dim(yRec);
    if yRec(y) > 0 then do;
		rrefuse = 0; drefuse = 0;
		rdk = 0;     ddk = 0; 
        do m=1 to 12;
			if dolYM(y,m) = -1 then drefuse = 1;
			else if dolYM(y,m) in (-2 -3) then ddk = 1; 
            if recYM(y,m) = -1 then rrefuse = 1;
			else if recYM(y,m) = -2 then rdk = 1;
		end;
		if rrefuse = 1 then yRecMo(y) = -1;
		else if rdk = 1 then yRecMo(y) = -2;
		else do; 
	        yRecMo(y) = 0;
	        do m=1 to 12;
	            if recYM(y,m) = 1 then yRecMo(y)=yRecMo(y)+1;
	        end;
	    end;		
	    if rrefuse = 1 or drefuse = 1 then yDol(y) = -3;
		else if rdk = 1 or ddk = 1 then yDol(y) = -3;   
		else do;
	        yDol(y) = 0;
	        do m=1 to 12;
	            if 0 <= dolYM(y,m) then yDol(y)=yDol(y)+dolYM(y,m); 
	        end;
	    end;
	end;
	else do;
		yDol(y)=yRec(y);
		yRecMo(y)=yRec(y);
	end;
end;
/* ==========================================================================
 *  Flag yearly amount that are not within possible bounds.
 * ========================================================================== */
array yFlg(*)   yFlg78-yFlg&cEndYr; 
array cMinDol (&cYrs) _temporary_ (&cYrs*46);  
array cMaxDol (&cYrs) _temporary_
    (244 275 316 344 342 360 364 366 400 415 472 511 549 544 550 555 560 568 568 735 735 835 835 969 22*814);
    
do y=1 to dim(yRec);
    yFlg(y) = 0;    
    if yRec(y) = -5 then yFlg(y)=-5;
    if yDol(y) < 0 then continue; 
	avgDol = yDol(y) / yRecMo(y);
    if avgDol < cMinDol(y) then
		yFlg(y)=1;
	else if cMaxDol(y) < avgDol then do;
        yFlg(y)=2;
        if cMinDol(y) <= avgDol / yRecMo(y) <= cMaxDol(y) then yFlg(y)=3;
    end;
end;
/* ==========================================================================
 *   DLI yearly amount  
 * ========================================================================== */
do y=1 to dim(yRec);
    if yDol(y) = .  then yDol(y)=-4;
    if yRec(y) = -4 then yRec(y)=0;
end;
yflag=0;
array ydolo(*)   fyDolo78-fyDolo&cEndYr;
do i=1 to dim(ydol);
 if lintyr=i+77 & 0<lintmo<13 then do;
  if ydol(i)=-4 then do; ydol(i)=ydolo(i); yflag=1; end;
  else if ydol(i)>=0 & ydolo(i) not in (-4 0) then do;
    if ydolo(i)>0 then do; ydol(i)=ydol(i)+ydolo(i); yflag=2; end;
	else if ydolo(i) in (-1 -2 -3) then do; ydol(i)=ydolo(i); yflag=3; end;
  end;
 end;
end;

Respondent/Dependent Child/Spouse/Partner SSI/SSDI Receipt

%let cEndYr = 123;		*(2023-1900);
%let cEndMo = 1488;     *(123+1)*12;
%let cYrs = 46;			*(2023-1978)+1;
%let cMos = 552;		*46*12;
%let cFillFlag = 2022;
data Q13;
 set prg2022.in_inc_2022;
 
VARIABLE NAMES IN PUBLIC RELEASE		VARIABLE NAMES IN PROGRAM
 Q13-37_2022                   				Q37                            		  
 Q13SSI-43A~000001_2022        				qr43A1                 
 Q13SSI-43A~000002_2022        				qr43A2                 
 Q13SSI-43A~000003_2022        				qr43A3                 
 Q13SSI-43A-NOKIDS_2022        				qr43ANOKIDS                 
 Q13SSI-A_2022                 				qrA                          
 Q13SSI-B1_2022                				qrB1                         
 Q13SSI-B2_2022                				qrB2                         
 Q13SSI-B3_2022                				qrB3                         
 Q13SSI-43D~000001_2022        				qr43D1                 
 Q13SSI-43D~000002_2022        				qr43D2                 
 Q13SSI-43D~000003_2022        				qr43D3                 
 Q13SSI-43C.01~M_2022          				qr43C1m                   
 Q13SSI-43C.01~Y_2022          				qr43C1y                   
 Q13SSI-43C.02~M_2022          				qr43C2m                   
 Q13SSI-43C.02~Y_2022          				qr43C2y                   
 Q13SSI-43C.03~M_2022          				qr43C3m                   
 Q13SSI-43C.03~Y_2022          				qr43C3y                   
 Q13SSI-44A1_CHK1.01.01_2022   				qr44A1CHK111            
 Q13SSI-44A1_CHK1.01.02_2022   				qr44A1CHK112            
 Q13SSI-44A1_CHK1.01.03_2022   				qr44A1CHK113            
 Q13SSI-44A1_CHK1.02.01_2022   				qr44A1CHK121            
 Q13SSI-44A1_CHK1.03.01_2022   				qr44A1CHK131            
 Q13SSI-44A1_CHK1.03.02_2022   				qr44A1CHK132            
 Q13SSI-44A3.01.01_2022        				qr44A311                 
 Q13SSI-44A3.01.02_2022        				qr44A312                 
 Q13SSI-44A3.01.03_2022        				qr44A313                 
 Q13SSI-44A3.02.01_2022        				qr44A321                 
 Q13SSI-44A3.03.01_2022        				qr44A331                 
 Q13SSI-44A3.03.02_2022        				qr44A332                 
 Q13SSI-44A5.01.01_2022        				qr44A511                 
 Q13SSI-44A5.02.01_2022        				qr44A521                 
 Q13SSI-44A5.03.01_2022        				qr44A531                 
 Q13SSI-44A6.01.01_2022        				qr44A611                 
 Q13SSI-44A6.02.01_2022        				qr44A621                 
 Q13SSI-44A6.03.01_2022        				qr44A631                 
 Q13SSI-44B.01.02_2022         				qr44B12                  
 Q13SSI-44B.01.03_2022         				qr44B13                  
 Q13SSI-44B.03.02_2022         				qr44B32                  
 Q13SSI-44C.01.02~M_2022       				qr44C12m                
 Q13SSI-44C.01.02~Y_2022       				qr44C12y                
 Q13SSI-44C.01.03~M_2022       				qr44C13m                
 Q13SSI-44C.01.03~Y_2022       				qr44C13y                
 Q13SSI-44C.03.02~M_2022       				qr44C32m                
 Q13SSI-44C.03.02~Y_2022       				qr44C32y                
 Q13SSI-44D.01.01_2022         				qr44D11                  
 Q13SSI-44D.01.02_2022         				qr44D12                  
 Q13SSI-44D.01.03_2022         				qr44D13                  
 Q13SSI-44D.02.01_2022         				qr44D21                  
 Q13SSI-44D.03.01_2022         				qr44D31                  
 Q13SSI-44D.03.02_2022         				qr44D32                  
 Q13SSI-45A.01.01_2022         				qr45A11                         
 Q13SSI-45A.01.02_2022         				qr45A12                         
 Q13SSI-45A.02.01_2022         				qr45A21                         
 Q13SSI-45A.03.01_2022         				qr45A31                         
 Q13SSI-45B.01.01~M_2022       				qr45B11m                       
 Q13SSI-45B.01.01~Y_2022       				qr45B11y                       
 Q13SSI-45B.01.02~M_2022       				qr45B12m                       
 Q13SSI-45B.01.02~Y_2022       				qr45B12y                       
 Q13SSI-45B.02.01~M_2022       				qr45B21m                       
 Q13SSI-45B.02.01~Y_2022       				qr45B21y                       
 Q13SSI-45B.03.01~M_2022       				qr45B31m                       
 Q13SSI-45B.03.01~Y_2022       				qr45B31y                       
 Q13SSI-47E.01.01_2022         				qr47E11                         
 Q13SSI-47E.01.02_2022         				qr47E12                         
 Q13SSI-47E.01.03_2022         				qr47E13                         
 Q13SSI-47E.02.01_2022         				qr47E21                         
 Q13SSI-47E.03.01_2022         				qr47E31                         
 Q13SSI-47E.03.02_2022         				qr47E32                         
 Q13SSI-62.01.01_2022          				qr6211                          
 Q13SSI-62.01.02_2022          				qr6212                          
 Q13SSI-62.01.03_2022          				qr6213                          
 Q13SSI-62.02.01_2022          				qr6221                          
 Q13SSI-62.03.01_2022          				qr6231                          
 Q13SSI-62.03.02_2022          				qr6232                          
 Q13SSI-62A.01.01_2022         				qr62A11                         
 Q13SSI-62A.01.02_2022         				qr62A12                         
 Q13SSI-62A.02.01_2022         				qr62A21                         
 Q13SSI-62A.03.01_2022         				qr62A31                         
 Q13SSI-63.02.01_2022          				qr6321                          
 Q13SSI-63.03.01_2022          				qr6331                          
 Q13SSI-63AB.01.01_2022        				qr63AB11                        
 Q13SSI-63B.01.01_2022         				qr63B11                         
 Q13SSI-63C.01.01_2022         				qr63C11                         
 Q13SSI-63C.01.02_2022         				qr63C12                         
 Q13SSI-63C.02.01_2022         				qr63C21                         
 Q13SSI-63C.03.01_2022         				qr63C31                     
 Q13SSI-63D.01.01_2022         				qr63D11                     
 Q13SSI-63D.01.02_2022         				qr63D12                     
 Q13SSI-63D.02.01_2022         				qr63D21                     
 Q13SSI-63D.03.01_2022         				qr63D31                     
 Q13SSI-64.01.01_2022          				qr6411                      
 Q13SSI-64.01.02_2022          				qr6412                      
 Q13SSI-64.02.01_2022          				qr6421                      
 Q13SSI-64.03.01_2022          				qr6431                      
 Q13SSI-64A.01.01_2022         				qr64A11                     
 Q13SSI-64A.01.02_2022         				qr64A12                     
 Q13SSI-64A.01.03_2022         				qr64A13                     
 Q13SSI-64A.02.01_2022         				qr64A21                     
 Q13SSI-64A.03.01_2022         				qr64A31                     
 Q13SSI-64A.03.02_2022         				qr64A32                      
 Q13SSI-SP-43A_2022            				qs43A                        
 Q13SSI-SP-43D~000001_2022     				qs43D1                 
 Q13SSI-SP-43D~000002_2022     				qs43D2                 
 Q13SSI-SP-43D~000003_2022     				qs43D3                 
 Q13SSI-SP-44A1_CHK1.01.01_2022				qs44A1CHK111            
 Q13SSI-SP-44A1_CHK1.01.02_2022				qs44A1CHK112            
 Q13SSI-SP-44A1_CHK1.01.03_2022				qs44A1CHK113            
 Q13SSI-SP-44A1_CHK1.02.01_2022				qs44A1CHK121            
 Q13SSI-SP-44A1_CHK1.02.02_2022				qs44A1CHK122            
 Q13SSI-SP-44A1_CHK1.02.03_2022				qs44A1CHK123            
 Q13SSI-SP-44A1_CHK1.03.01_2022				qs44A1CHK131            
 Q13SSI-SP-44A1_CHK1.03.02_2022				qs44A1CHK132            
 Q13SSI-SP-44A1_CHK1.03.03_2022				qs44A1CHK133  
 Q13SSI-SP-44A3.01.01_2022     				qs44A311                 
 Q13SSI-SP-44A3.01.02_2022     				qs44A312                 
 Q13SSI-SP-44A3.01.03_2022     				qs44A313                 
 Q13SSI-SP-44A3.02.01_2022     				qs44A321                 
 Q13SSI-SP-44A3.02.02_2022     				qs44A322                 
 Q13SSI-SP-44A3.02.03_2022     				qs44A323                 
 Q13SSI-SP-44A3.03.01_2022     				qs44A331                 
 Q13SSI-SP-44A3.03.02_2022     				qs44A332                 
 Q13SSI-SP-44A3.03.03_2022     				qs44A333  
 Q13SSI-SP-44A5.01.01_2022     				qs44A511                 
 Q13SSI-SP-44A5.02.01_2022     				qs44A521                 
 Q13SSI-SP-44A5.03.01_2022     				qs44A531                 
 Q13SSI-SP-44A6.01.01_2022     				qs44A611                 
 Q13SSI-SP-44A6.02.01_2022     				qs44A621                 
 Q13SSI-SP-44A6.03.01_2022     				qs44A631                 
 Q13SSI-SP-44B.01.01_2022      				qs44B11                  
 Q13SSI-SP-44B.01.02_2022      				qs44B12                  
 Q13SSI-SP-44B.01.03_2022      				qs44B13                  
 Q13SSI-SP-44B.02.01_2022      				qs44B21                  
 Q13SSI-SP-44B.02.02_2022      				qs44B22                  
 Q13SSI-SP-44B.02.03_2022      				qs44B23                  
 Q13SSI-SP-44B.03.01_2022      				qs44B31                  
 Q13SSI-SP-44B.03.02_2022      				qs44B32                  
 Q13SSI-SP-44B.03.03_2022      				qs44B33   
 Q13SSI-SP-44C.01.01~M_2022    				qs44C11m                
 Q13SSI-SP-44C.01.01~Y_2022    				qs44C11y                
 Q13SSI-SP-44C.01.02~M_2022    				qs44C12m                
 Q13SSI-SP-44C.01.02~Y_2022    				qs44C12y                
 Q13SSI-SP-44C.01.03~M_2022    				qs44C13m                
 Q13SSI-SP-44C.01.03~Y_2022    				qs44C13y                
 Q13SSI-SP-44C.02.01~M_2022    				qs44C21m                
 Q13SSI-SP-44C.02.01~Y_2022    				qs44C21y                
 Q13SSI-SP-44C.02.02~M_2022    				qs44C22m                
 Q13SSI-SP-44C.02.02~Y_2022    				qs44C22y                
 Q13SSI-SP-44C.03.01~M_2022    				qs44C31m                
 Q13SSI-SP-44C.03.01~Y_2022    				qs44C31y                
 Q13SSI-SP-44C.03.03~M_2022    				qs44C33m  
 Q13SSI-SP-44C.03.03~Y_2022    				qs44C33y  
 Q13SSI-SP-44D.01.01_2022      				qs44D11                  
 Q13SSI-SP-44D.01.02_2022      				qs44D12                  
 Q13SSI-SP-44D.01.03_2022      				qs44D13                  
 Q13SSI-SP-44D.02.01_2022      				qs44D21                  
 Q13SSI-SP-44D.02.02_2022      				qs44D22                  
 Q13SSI-SP-44D.03.01_2022      				qs44D31                  
 Q13SSI-SP-44D.03.03_2022      				qs44D33   
 Q13SSI-SP-45A.02.01_2022      				qs45A21                  
 Q13SSI-SP-45B.02.01~M_2022    				qs45B21m                
 Q13SSI-SP-45B.02.01~Y_2022    				qs45B21y                
 Q13SSI-SP-47E.01.01_2022      				qs47E11                  
 Q13SSI-SP-47E.01.02_2022      				qs47E12                  
 Q13SSI-SP-47E.01.03_2022      				qs47E13                  
 Q13SSI-SP-47E.02.01_2022      				qs47E21                  
 Q13SSI-SP-47E.02.02_2022      				qs47E22                  
 Q13SSI-SP-47E.03.01_2022      				qs47E31                  
 Q13SSI-SP-47E.03.03_2022      				qs47E33   
 Q13SSI-SP-62.01.01_2022       				qs6211                   
 Q13SSI-SP-62.01.02_2022       				qs6212                   
 Q13SSI-SP-62.01.03_2022       				qs6213                   
 Q13SSI-SP-62.02.01_2022       				qs6221                   
 Q13SSI-SP-62.02.02_2022       				qs6222                   
 Q13SSI-SP-62.03.01_2022       				qs6231                   
 Q13SSI-SP-62.03.03_2022       				qs6233    
 Q13SSI-SP-62A.02.01_2022      				qs62A21                 
 Q13SSI-SP-63AA.01.01_2022     				qs63AA11                 
 Q13SSI-SP-63AA.01.02_2022     				qs63AA12                 
 Q13SSI-SP-63AA.02.01_2022     				qs63AA21                 
 Q13SSI-SP-63AA.02.02_2022     				qs63AA22                 
 Q13SSI-SP-63AA.02.03_2022     				qs63AA23                 
 Q13SSI-SP-63AA.03.01_2022     				qs63AA31                 
 Q13SSI-SP-63AA.03.02_2022     				qs63AA32  
 Q13SSI-SP-63B.01.01_2022      				qs63B11                  
 Q13SSI-SP-63B.01.02_2022      				qs63B12                  
 Q13SSI-SP-63B.02.01_2022      				qs63B21                  
 Q13SSI-SP-63B.02.02_2022      				qs63B22                  
 Q13SSI-SP-63B.02.03_2022      				qs63B23                  
 Q13SSI-SP-63B.03.01_2022      				qs63B31                  
 Q13SSI-SP-63B.03.02_2022      				qs63B32   
 Q13SSI-SP-63C.01.01_2022      				qs63C11                  
 Q13SSI-SP-63C.01.02_2022      				qs63C12                  
 Q13SSI-SP-63C.02.01_2022      				qs63C21                  
 Q13SSI-SP-63C.02.02_2022      				qs63C22                  
 Q13SSI-SP-63C.02.03_2022      				qs63C23                  
 Q13SSI-SP-63C.03.01_2022      				qs63C31                  
 Q13SSI-SP-63C.03.02_2022      				qs63C32   
 Q13SSI-SP-63D.01.01_2022      				qs63D11                  
 Q13SSI-SP-63D.01.02_2022      				qs63D12                  
 Q13SSI-SP-63D.02.01_2022      				qs63D21                  
 Q13SSI-SP-63D.02.02_2022      				qs63D22                  
 Q13SSI-SP-63D.02.03_2022      				qs63D23                  
 Q13SSI-SP-63D.03.01_2022      				qs63D31                  
 Q13SSI-SP-63D.03.02_2022      				qs63D32   
 Q13SSI-SP-64.01.01_2022       				qs6411                   
 Q13SSI-SP-64.01.02_2022       				qs6412                   
 Q13SSI-SP-64.02.01_2022       				qs6421                   
 Q13SSI-SP-64.02.02_2022       				qs6422                   
 Q13SSI-SP-64.02.03_2022       				qs6423                   
 Q13SSI-SP-64.03.01_2022       				qs6431                   
 Q13SSI-SP-64.03.02_2022       				qs6432    
 Q13SSI-SP-64A.01.01_2022      				qs64A11                  
 Q13SSI-SP-64A.01.02_2022      				qs64A12                  
 Q13SSI-SP-64A.01.03_2022      				qs64A13                  
 Q13SSI-SP-64A.02.01_2022      				qs64A21                  
 Q13SSI-SP-64A.02.02_2022      				qs64A22                  
 Q13SSI-SP-64A.03.01_2022      				qs64A31                  
 Q13SSI-SP-64A.03.03_2022      				qs64A33   
 Q13-10_2022   	               				Q10
 CURDATE~D_2022   	           				intDay	
 CURDATE~M_2022                				intMo 
 CURDATE~Y_2022                				intYr;
                                          
data recip1;
 merge R30.lintdate2022 Q13 
 prg2022.oldin2022 (keep=norcid sydolo: dydolo: r30bydolo:);
 by norcid;
 if (intMo > 0);
noInt=0;
                      
data recip;
 set recip1;
 
* convert Y2K changes to simple years;
array yrs (*) intYr 
              qr43C1y qr43C2y qr43C3y
			  qr44C12y qr44C13y qr44C32y
			  qr45B11y qr45B12y qr45B21y qr45B31y
			  qs44C11y qs44C12y qs44C13y qs44C21y qs44C22y qs44C31y qs44C33y
			  qs45B21y;
do i=1 to dim(yrs);
    if yrs(i) > 0 then yrs(i)=yrs(i)-1900;
end;
* date of this interview;
intDt=intYr*12+intMo;
/* ==========================================================================
  Merge info from several sources + convert weeks to months.
  ========================================================================== */
dummy = -4;   
	qr44c11y=qr43c1y; qr44c21y=qr43c2y; qr44c31y=qr43c3y;
	qr44c11m=qr43c1m; qr44c21m=qr43c2m; qr44c31m=qr43c3m;
array nrOfRMos (6,3) qr63ab11 dummy dummy
					 dummy dummy dummy
					 dummy dummy dummy
					 qs63aa11 qs63aa12 dummy
					 qs63aa21 qs63aa22 qs63aa23 
					 qs63aa31 qs63aa32 dummy;
array howMuch (6,3) qr47e11 qr47e12 qr47e13
					qr47e21 dummy dummy
					qr47e31 qr47e32 dummy
					qs47e11 qs47e12 qs47e13
					qs47e21 qs47e22 dummy
					qs47e31 dummy  qs47e33;
array q63b  (6,3)   qr63b11 dummy dummy
					dummy dummy dummy
					dummy dummy dummy
					qs63b11 qs63b12 dummy
					qs63b21 qs63b22 qs63b23
					qs63b31 qs63b32 dummy;
					
do i=1 to 6;
  do j=1 to 3;
    if howMuch(i,j) = -4 then howMuch(i,j) = q63b(i,j);  
  end;
end;
array check (*) check1-check6;	
do i=1 to 6; check(i)=0; end;
array startMo (6,3) qr44c11m qr44c12m qr44c13m
					qr44c21m qr44c22m qr44c23m
					qr44c31m qr44c32m qr44c33m
					qs44c11m qs44c12m qs44c13m
					qs44c21m qs44c22m qs44c23m
					qs44c31m qs44c32m qs44c33m;					
array startYr (6,3) qr44c11y qr44c12y qr44c13y
					qr44c21y qr44c22y qr44c23y
					qr44c31y qr44c32y qr44c33y
					qs44c11y qs44c12y qs44c13y
					qs44c21y qs44c22y qs44c23y
					qs44c31y qs44c32y qs44c33y;						         
array endMo   (6,3) qr45B11m qr45B12m qr45B13m
					qr45B21m qr45B22m qr45B23m
					qr45B31m qr45B32m qr45B33m
					qs45B11m qs45B12m qs45B13m
					qs45B21m qs45B22m qs45B23m
					qs45B31m qs45B32m qs45B33m;
array endYr   (6,3) qr45B11y qr45B12y qr45B13y
					qr45B21y qr45B22y qr45B23y
					qr45B31y qr45B32y qr45B33y
					qs45B11y qs45B12y qs45B13y
					qs45B21y qs45B22y qs45B23y
					qs45B31y qs45B32y qs45B33y;
array cont    (6,3) qr44d11 qr44d12 qr44d13
					qr44d21 qr44d22 qr44d23
					qr44d31 qr44d32 qr44d33
					qs44d11 qs44d12 qs44d13
					qs44d21 qs44d22 qs44d23
					qs44d31 qs44d32 qs44d33;
array q44b    (6,3) qr44b11 qr44b12 qr44b13 
					qr44b21 qr44b22 qr44b23
					qr44b31 qr44b32 qr44b33
					qs44b11 qs44b12 qs44b13
					qs44b21 qs44b22 qs44b23
					qs44b31 qs44b32 qs44b33;
array q43b    (*) qr43b1-qr43b3 qs43b1-qs43b3; 
array q63c    (6,3) qr63c11 qr63c12 qr63c13
					qr63c21 qr63c22 qr63c23
					qr63c31 qr63c32 qr63c33
					qs63c11 qs63c12 qs63c13
					qs63c21 qs63c22 qs63c23
					qs63c31 qs63c32 qs63c33;
array starts (6,3) starts11-starts13 starts21-starts23 starts31-starts33
				   starts41-starts43 starts51-starts53 starts61-starts63;  
array ends   (6,3) ends11-ends13 ends21-ends23 ends31-ends33
				   ends41-ends43 ends51-ends53 ends61-ends63;  
array seamFlag (*) seamFlag1-seamFlag6;
array last (*) last1-last6;
array rs(6,3) rs11-rs13 rs21-rs23 rs31-rs33
              rs41-rs43 rs51-rs53 rs61-rs63;  * Recipiency starts; 
array re(6,3) re11-re13 re21-re23 re31-re33
              re41-re43 re51-re53 re61-re63;  * Recipiency ends;
array ns(6,4) ns11-ns14 ns21-ns24 ns31-ns34
              ns41-ns44 ns51-ns54 ns61-ns64;  * Nonrecipiency starts (# of spells + 1, potentialy bef and after);
array ne(6,4) ne11-ne14 ne21-ne24 ne31-ne34
              ne41-ne44 ne51-ne54 ne61-ne64;  * Nonrecipiency ends; 
array chk5 (*) chk51-chk56;
				
/* ==========================================================================
   Recipiency status (rec) and amounts (dol) by months
   All months from 1978jan till dec of current year, indexed from 1900jan.
   78*12+1 = 937
   ========================================================================== */
array rec (6, 937:&cEndMo) rec1_1-rec1_&cMos rec2_1-rec2_&cMos rec3_1-rec3_&cMos
						   rec4_1-rec4_&cMos rec5_1-rec5_&cMos rec6_1-rec6_&cMos;    
array dol (6, 937:&cEndMo) dol1_1-dol1_&cMos dol2_1-dol2_&cMos dol3_1-dol3_&cMos
						   dol4_1-dol4_&cMos dol5_1-dol5_&cMos dol6_1-dol6_&cMos;    
  
array q43d (*) qr43d1-qr43d3 qs43d1-qs43d3;
/* ========================================================================== 
 * No/unknown recipiency
 * ========================================================================== */
if qr43a3=1 or qr43ANOKIDS=0 then do i=1 to 3;
 do m=lint to intDt;
   rec(i,m)=-4;
   dol(i,m)=-4;
 end;
end;
if q10=0 or qs43a=0 then do i=4 to 6;
 do m=lint to intDt;
   rec(i,m)=-4;
   dol(i,m)=-4;
 end;
end;
if qr43a1 in (-1 -2 -3) or qr43ANOKIDS in (-1 -2 -3) or qr43D1 in (-1 -2 -3) then do i=1 to 3;
 do m=lint to intDt;
   rec(i,m)=-3;
   dol(i,m)=-3;
 end;
end;
if qs43a in (-1 -2 -3) or qs43d1 in (-1 -2 -3) then do i=4 to 6;
 do m=lint to intDt;
   rec(i,m)=-3;
   dol(i,m)=-3;
 end;
end;
/* ==========================================================================
 * There was some recipiency, get details
 * ========================================================================== */
do i=1 to 6;
if q43d(i)=0 then do m=lint to intDt;
  rec(i,m)=-4;
  dol(i,m)=-4;
end;
else if q43d(i)=1 then do;
/* -----------------------------------------------------------------------------
 * Calculate starts and ends of spells if possible
 * -----------------------------------------------------------------------------*/
* Continuous recipiency "ends" at interview date;
 do s = 1 to dim2(cont);
	if cont(i,s) = 1 or q63c(i,s)=13 then do; 
        endYr(i,s) = intYr;
        endMo(i,s) = intMo;
    end;
 end;
 
* Compute starts/stops/last for basic cases (dates are known);
 do s = 1 to dim2(starts);
    if startMo(i,s) > 0 & startYr(i,s) > 0 then
        starts(i,s) = startYr(i,s)*12+startMo(i,s);
    if endMo(i,s) > 0 & endYr(i,s) > 0 then
        ends(i,s) = endYr(i,s)*12+endMo(i,s);
 end;
 
 seamFlag(i)=0;
 do s = 1 to dim2(starts);
	if starts(i,s) > 0 then do;
        if starts(i,s)=lint   then seamFlag(i)=1; 
        if starts(i,s)=lint-1 then seamFlag(i)=2; 
		if 0<starts(i,s)<lint-1 then seamFlag(i)=3;
	end;
 end;
 
lint_real=lint-936-1;  
 do s=1 to dim2(starts);
  if starts(i,s) > 0 & starts(i,s)<lint then starts(i,s)=lint;
 end;
 
* Try to deduce starts/ends from # of mos;
 do s = 1 to dim2(starts);
    if nrOfRMos(i,s) > 0 then do;  
	    if ends(i,s) > 0 & starts(i,s) = .  then do;         
            starts(i,s) = ends(i,s) - nrOfRMos(i,s)+1;
			check(i)=5.1; 
            if (starts(i,s) < lint) then check(i) = 5;
        end;
		else if starts(i,s) > 0 & ends(i,s) = .  then do;
            ends(i,s) = starts(i,s) + nrOfRMos(i,s) - 1;
			check(i)=100+s+0.1;
			if ends(i,s)>intDt then check(i)=100+s;  
        end;
		else if starts(i,s) = .  & ends(i,s) = .  then do; 
            if s = 1 then do; starts(i,s) = lint; check(i)=201+0.1; end;    
			else do; starts(i,s) = ends(i,s-1) + 1; check(i)=200+s+0.1; end;
            ends(i,s) = starts(i,s) + nrOfRMos(i,s) - 1;
			if ends(i,s)>intDt then check(i)=200+s; 
        end;
    end;
 end;	
 
/* Determine what was the last spell */
 last(i) = 0;
 if q44b(i,1)=2 or q43B(i) = 2 then last(i) = 1; 
 do s = 1 to dim2(starts);
    if ((startMo(i,s) > 0 | startYr(i,s) > 0 | endMo(i,s) > 0 | endYr(i,s) > 0 |nrOfRMos (i,s) > 0) & last(i) < s) then last(i) = s;
 end;
 
/* -----------------------------------------------------------------------------
 * Edges of recipiency spells and periods between: n1 r1 n2 r2 ...  (NNNRRR???NRRR)
 * Under ideal conditions they touch, but often there is an unclear zone between them (-2)
 * ----------------------------------------------------------------------------- */
* The fully known cases;
 if last(i) ge 1 then do s = 1 to last(i);
    if starts(i,s) > 0 then do;
        ne(i,s) = starts(i,s)-1;
        rs(i,s) = starts(i,s);
    end;
    if ends(i,s) > 0 then do;
        re(i,s)   = ends(i,s);
        ns(i,s+1) = ends(i,s)+1;
    end;
 end;
 
* The unknown and partially known cases;
  if last(i) ge 1 then do s = 1 to last(i);
    if starts(i,s) = . & startYr(i,s) > 0 then do;
		check(i)=301; 
        xne = startYr(i,s)*12;  
        if ( s = 1 & lint < =xne ) |
           ( s > 1 & 0 < ends(i,s-1) < xne) |
           ( s > 1 & 0 < endYr(i,s-1) + 1 < startYr(i,s) )
            then do; ne(i,s) = xne; check(i)=302; end; 
        if startYr(i,s) < endYr(i,s) then do;
            rs(i,s) = startYr(i,s)*12+12;   
			check(i)=303;  
		end;
    end;
    if (ends(i,s) = . & endYr(i,s) > 0) then do;
		check(i)=401;
        if 0 < startYr(i,s) < endYr(i,s) then do;
            re(i,s) = endYr(i,s)*12+1;    
            ns(i,s+1) = endYr(i,s)*12+13; 
			check(i)=402;
		end;
		if 0 < startYr(i,s) = endYr(i,s) then do; 
		  ns(i,s+1)=endYr(i,s)*12+13;
		  if rs(i,s)>0 then do;
			re(i,s)=rs(i,s); 
		  end;
		  check(i)=403;
		end;
    end;
 end;
 if (ne(i,1) > 0) then ns(i,1) = lint;                  
 if (ns(i,last(i)+1) > 0) then ne(i,last(i)+1) = intDt; 
 if last(i)>1 then do s = 2 t o last(i);
	if 0 < rs(i,s) & rs(i,s) = re(i,s-1) then check(i) = 7;
 end;
 
/* -----------------------------------------------------------------------------
 * Fill the recipiency status (rec) and amounts (dol).
 * ----------------------------------------------------------------------------- */
* First, assume we know nothing;
 do m = lint to intDt;
    rec(i,m) = -2;
    dol(i,m) = -2;
 end;
 
* Fill in info we know (any of the periods below can be empty);
  if last(i) ge 1 then do s = 1 to last(i);
    * nonrecipiency period;
    if (0 < ns(i,s) <= ne(i,s)) then
        do m = max(ns(i,s),lint) to min(ne(i,s),intDt);
            rec(i,m) = -4;
            dol(i,m) = -4;
        end;
    * recipiency period;
    if (0 < rs(i,s) <= re(i,s)) then
        do m = max(rs(i,s),lint) to min(re(i,s),intDt);
            rec(i,m) = 1;
            dol(i,m) = howMuch(i,s);
			if howmuch(i,s) in (. -4) then do; dol(i,m)=-2; chk5(i)=s+0.1; end; 
        end;
    * we know only start - we are sure R received smth that month;
    else if (lint <= rs(i,s) <= intDt & re(i,s) = .) then do; 
        rec(i, rs(i,s)) = 1;
        dol(i, rs(i,s)) = howMuch(i,s);
		if howmuch(i,s) in (. -4) then do; dol(i, rs(i,s))=-2; chk5(i)=s+0.2; end;
    end;
    * we know only end - we are sure R received smth that month (can be even intDt if continuous);
    else if (rs(i,s) = . & lint <= re(i,s) <= intDt) then do;
        rec(i,re(i,s)) = 1;
        dol(i,re(i,s)) = howMuch(i,s);
		if howmuch(i,s) in (. -4) then do; dol(i, re(i,s))=-2; chk5(i)=s+0.3; end;
    end;
 end;
 
* The last period of nonrecipiency;
  if last(i) ge 1 then do;
    if (0 < ns(i, last(i)+1) <= ne(i, last(i)+1)) then
    do m = max(lint,ns(i, last(i)+1)) to min(ne(i,last(i)+1),intDt);
        rec(i,m) = -4;
        dol(i,m) = -4;
    end;
  end;
  
end;
end;
/* ========================================================================== */
/* End if recip = .... (getting details for people who got something)
/* ========================================================================== */
do i=1 to dim1(starts);
 do m=intDt+1 to hbound2(rec);
    rec(i,m)=-4;
    dol(i,m)=-4;
 end;
end;
endDt=intDt-936;
do i=1 to dim1(starts);
 if startMo(i,1) in (-1,-2) & startYr(i,1) in (-1,-2) then q43b(i) = 2;
end;
if noInt=0 then
    do i=1 to dim1(rec);
	  do m=lbound2(rec) to hbound2(rec);
        if rec(i,m)=. then rec(i,m)=-4;
        if dol(i,m)=. then dol(i,m)=-4;
	  end;
    end;
if noInt=1 then
    do i=1 to dim1(rec);
	 do m=lbound2(rec) to hbound2(rec);
        if rec(i,m)=. then rec(i,m)=-5;
        if dol(i,m)=. then dol(i,m)=-5;
	 end;
    end;
    
********** the respondent and spouse monthly amount;
***** respondent ssb (the sum of ssi and ssdi);
array rssb (937:&cEndMo) rssb1-rssb&cMos;
do m = lbound(rssb) to hbound(rssb);
   rssb(m)=-4;
end;   
if qr43d3=1 then do m = lint to intdt;
 if dol(3,m)>-4 then do;
  dol(1,m)=-3;
  dol(2,m)=-3;
  rssb(m)=dol(3,m);
 end;
end;
else do m = lint to intDt;
 if dol(1,m)=-4 & dol(2,m)=-4 then rssb(m)=-4;
 else if dol(1,m) in (-1 -2 -3) or dol(2,m) in (-1 -2 -3) then rssb(m)=-3;
 else rssb(m)=max(dol(1,m),0) + max(dol(2,m),0);
end;
***** spouse ssb (both ssi and ssdi);
array sssb (937:&cEndMo) sssb1-sssb&cMos;
do m = lbound(sssb) to hbound(sssb);
   sssb(m)=-4;
end;   
if qs43d3=1 then do m = lint to intdt;
 if dol(6,m)>-4 then do;
  dol(4,m)=-3;
  dol(5,m)=-3;
  sssb(m)=dol(6,m);
 end;
end;
else do m = lint to intDt;
 if dol(4,m)=-4 & dol(5,m)=-4 then sssb(m)=-4;
 else if dol(4,m) in (-1 -2 -3) or dol(5,m) in (-1 -2 -3) then sssb(m)=-3;
 else sssb(m)=max(dol(4,m),0) + max(dol(5,m),0);
end;
********** add up the respondent and the spouse monthly amount to come up with ssi, ssd and ssb;
***** ssi;
array ssi (937:&cEndMo) ssi1-ssi&cMos;
do m = lbound(ssi) to hbound(ssi);
   ssi(m)=-4;
end;   
do m = lint to intDt;
 if dol(1,m)=-4 & dol(4,m)=-4 then ssi(m)=-4;
 else if dol(1,m) in (-1 -2 -3) or dol(4,m) in (-1 -2 -3) then ssi(m)=-3;
 else ssi(m)=max(dol(1,m),0) + max(dol(4,m),0);
end;
***** ssd;
array ssd (937:&cEndMo) ssd1-ssd&cMos;
do m = lbound(ssd) to hbound(ssd);
   ssd(m)=-4;
end;   
do m = lint to intDt;
 if dol(2,m)=-4 & dol(5,m)=-4 then ssd(m)=-4;
 else if dol(2,m) in (-1 -2 -3) or dol(5,m) in (-1 -2 -3) then ssd(m)=-3;
 else ssd(m)=max(dol(2,m),0) + max(dol(5,m),0);
end;
***** ssb;
array ssb (937:&cEndMo) ssb1-ssb&cMos;
do m = lbound(ssb) to hbound(ssb);
   ssb(m)=-4;
end;   
do m = lint to intDt;
 if rssb(m)=-4 & sssb(m)=-4 then ssb(m)=-4;
 else if rssb(m) in (-1 -2 -3) or sssb(m) in (-1 -2 -3) then ssb(m)=-3;
 else ssb(m)=max(rssb(m),0) + max(sssb(m),0);
end;
********** ssd & ssb array starting in Jan 2017;
if lintyr=117 then do; 
 if qr43d2 in (1 -1 -2 -3) or qr43d3=1 or qs43d2 in (1 -1 -2 -3) or qs43d3=1 then do;
  if lint>469 then do m=(469+936) to (lint-1);
   if ssd(m) in (-4 .) then ssd(m)=99999;
   if ssb(m) in (-4 .) then ssb(m)=99999;
  end;
 end;
 else do;
  if lint>469 then do m=(469+936) to (lint-1);
   if ssd(m) in (-4 .) then ssd(m)=99998;
   if ssb(m) in (-4 .) then ssb(m)=99998;
  end;
 end;
 *when we calculate the annual amount, we equate 99999 to -3 and 99998 to -4;
 
 if  ssd469=99999 and (qr43d2=1 or qs43d2=1) and (cases found in the comments) then do; 
  do m=(469+936) to &cEndMo;
   if -4<ssd(m)<99998 then do; ssd_1=ssd(m); ssd_1_m=m; m=&cEndMo;end;
  end;
  do m=(469+936) to &cEndMo;
   if ssd(m)=99999 then do; ssd(m)=ssd_1; ssb(m)=ssd_1; end; 
   else if ssd(m) ne 99999 then m=&cEndMo;
  end;
 end; 
end;
if  ssd469=99999 and ((qr43d2=1 & qr44c21m=1 & qr44c21y=2017) or
					  (qs43d2=1 & qs44c21m=1 & qs44c21y=2017)) then do;
 flag=1;
 do m=(469+936) to &cEndMo;
  if -4<ssd(m)<99998 then do; ssd_1a=ssd(m);ssd_1a_m=m; m=&cEndMo;end;
 end;
 do m=(469+936) to &cEndMo;
  if ssd(m)=99999 then do; ssd(m)=ssd_1a; ssb(m)=ssd_1a; end; 
  else if ssd(m) ne 99999 then m=&cEndMo;
 end;
end;
  
********** create the current round yearly ssi, ssd & ssb;
array ssiYM(&cYrs,12) ssi1-ssi&cMos;
array ssdYM(&cYrs,12) ssd1-ssd&cMos;
array ssbYM(&cYrs,12) ssb1-ssb&cMos;
array yssi(*)   yssi78-yssi&cEndYr;
array yssd1(*)   yssd78-yssd&cEndYr;
array yssb1(*)   yssb78-yssb&cEndYr;
%macro mty (vym, vy);
do y=1 to dim(&vy);
   m4=0; m3=0; mp=0;
   do m=1 to 12;
      if &vym(y,m) in (-4 . 99998) then m4=m4+1;
	  else if &vym(y,m) in (-1 -2 -3 99999) then m3=m3+1;
	  else if &vym(y,m)>=0 then mp=mp+1;
   end;
   if m3>0 then &vy(y)=-3;
   else if m4=12 then &vy(y)=-4;
   else do;
     &vy(y)=0;
	 do m=1 to 12;
	   if 0<&vym(y,m)<99998 then &vy(y)=&vy(y)+&vym(y,m);
	 end;
   end;
end;
%mend mty;
%mty(ssiYM, yssi);
%mty(ssdYM, yssd1);
%mty(ssbYM, yssb1);
********** connect the current round yearly variables to the old yearly variables;
array yssio(*)   syDolo78-syDolo&cEndYr;
array yssdo(*)   dyDolo117-dyDolo&cEndYr;
array yssbo(*)   r30byDolo117-r30byDolo&cEndYr;
array yssd(*)   yssd117-yssd&cEndYr; 
array yssb(*)   yssb117-yssb&cEndYr;
yiflag=0;
do Y=1 to dim(yssio);
 if lintyr=y+77 & 0<lintmo<13 then do;
  if yssi(y)=-4 then do; yssi(y)=yssio(y); yiflag=1; end;
  else if yssi(y)>=0 & yssio(y) not in (-4 0) then do;
    if yssio(y)>0 then do; yssi(y)=yssi(y)+yssio(y); yiflag=2; end;
	else if yssio(y) in (-1 -2 -3) then do; yssi(y)=yssio(y); yiflag=3; end;
  end;
 end;
end;
ydflag=0;
do Y=1 to dim(yssdo);
 if lintyr=y+116 & 0<lintmo<13 then do;
  if yssd(y)=-4 then do; yssd(y)=yssdo(y); ydflag=1; end;
  else if yssd(y)>=0 & yssdo(y) not in (-4 0) then do;
    if yssdo(y)>0 then do; yssd(y)=yssd(y)+yssdo(y); ydflag=2; end;
	else if yssdo(y) in (-1 -2 -3) then do; yssd(y)=yssdo(y); ydflag=3; end;
  end;
 end;
end;
ybflag=0;
do Y=1 to dim(yssbo);
 if lintyr=y+116 & 0<lintmo<13 then do;
  if yssb(y)=-4 then do; yssb(y)=yssbo(y); ybflag=1; end;
  else if yssb(y)>=0 & yssbo(y) not in (-4 0) then do;
    if yssbo(y)>0 then do; yssb(y)=yssb(y)+yssbo(y); ybflag=2; end;
	else if yssbo(y) in (-1 -2 -3) then do; yssb(y)=yssbo(y); ybflag=3; end;
  end;
 end;
end;

Summary Welfare (AFDC/TANF, Food Stamps/SNAP, SSI/SSDI) Receipt

%let cEndYr = 123;		*(2023-1900);
%let cEndMo = 1488;     *(123+1)*12;
%let cYrs = 46;			*(2023-1978)+1;
%let cMos = 552;		*46*12;
%let cFillFlag = 2022;
******* The following recipiency data includes the updates we had done in the current round; 
data one;
input  ;
VARIABLE NAMES IN PUBLIC RELEASE		VARIABLE NAMES IN PROGRAM
   CASEID_XRND                    			NORCID
   AFDC-TOTAL-1978_REVISED_XRND   			ay78
   FDSTMPS-TOTAL-1978_REVISED_XRND			fy78
   SSI-TOTAL-1978_REVISED_XRND    			siy78
   WELFARE-AMT-1978_REVISED_XRND  			wiyo78
   AFDC-TOTAL-1979_REVISED_XRND   			ay79
   FDSTMPS-TOTAL-1979_REVISED_XRND			fy79
   SSI-TOTAL-1979_REVISED_XRND    			siy79
   WELFARE-AMT-1979_REVISED_XRND  			wiyo79
   AFDC-TOTAL-1980_REVISED_XRND   			ay80
   FDSTMPS-TOTAL-1980_REVISED_XRND			fy80
   SSI-TOTAL-1980_REVISED_XRND    			siy80
   WELFARE-AMT-1980_REVISED_XRND  			wiyo80
   AFDC-TOTAL-1981_REVISED_XRND   			ay81
   FDSTMPS-TOTAL-1981_REVISED_XRND			fy81
   SSI-TOTAL-1981_REVISED_XRND    			siy81
   WELFARE-AMT-1981_REVISED_XRND  			wiyo81
   AFDC-TOTAL-1982_REVISED_XRND   			ay82
   FDSTMPS-TOTAL-1982_REVISED_XRND			fy82
   SSI-TOTAL-1982_REVISED_XRND    			siy82
   WELFARE-AMT-1982_REVISED_XRND  			wiyo82
   AFDC-TOTAL-1983_REVISED_XRND   			ay83
   FDSTMPS-TOTAL-1983_REVISED_XRND			fy83
   SSI-TOTAL-1983_REVISED_XRND    			siy83
   WELFARE-AMT-1983_REVISED_XRND  			wiyo83
   AFDC-TOTAL-1984_REVISED_XRND   			ay84
   FDSTMPS-TOTAL-1984_REVISED_XRND			fy84
   SSI-TOTAL-1984_REVISED_XRND    			siy84
   WELFARE-AMT-1984_REVISED_XRND  			wiyo84
   AFDC-TOTAL-1985_REVISED_XRND   			ay85
   FDSTMPS-TOTAL-1985_REVISED_XRND			fy85
   SSI-TOTAL-1985_REVISED_XRND    			siy85
   WELFARE-AMT-1985_REVISED_XRND  			wiyo85
   AFDC-TOTAL-1986_REVISED_XRND   			ay86
   FDSTMPS-TOTAL-1986_REVISED_XRND			fy86
   SSI-TOTAL-1986_REVISED_XRND    			siy86
   WELFARE-AMT-1986_REVISED_XRND  			wiyo86
   AFDC-TOTAL-1987_REVISED_XRND   			ay87
   FDSTMPS-TOTAL-1987_REVISED_XRND			fy87
   SSI-TOTAL-1987_REVISED_XRND    			siy87
   WELFARE-AMT-1987_REVISED_XRND  			wiyo87
   AFDC-TOTAL-1988_REVISED_XRND   			ay88
   FDSTMPS-TOTAL-1988_REVISED_XRND			fy88
   SSI-TOTAL-1988_REVISED_XRND    			siy88
   WELFARE-AMT-1988_REVISED_XRND  			wiyo88
   AFDC-TOTAL-1989_REVISED_XRND   			ay89
   FDSTMPS-TOTAL-1989_REVISED_XRND			fy89
   SSI-TOTAL-1989_REVISED_XRND    			siy89
   WELFARE-AMT-1989_REVISED_XRND  			wiyo89
   AFDC-TOTAL-1990_REVISED_XRND   			ay90
   FDSTMPS-TOTAL-1990_REVISED_XRND			fy90
   SSI-TOTAL-1990_REVISED_XRND    			siy90
   WELFARE-AMT-1990_REVISED_XRND  			wiyo90
   AFDC-TOTAL-1991_REVISED_XRND   			ay91
   FDSTMPS-TOTAL-1991_REVISED_XRND			fy91
   SSI-TOTAL-1991_REVISED_XRND    			siy91
   WELFARE-AMT-1991_REVISED_XRND  			wiyo91
   AFDC-TOTAL-1992_REVISED_XRND   			ay92
   FDSTMPS-TOTAL-1992_REVISED_XRND			fy92
   SSI-TOTAL-1992_REVISED_XRND    			siy92
   WELFARE-AMT-1992_REVISED_XRND  			wiyo92
   AFDC-TOTAL-1993_REVISED_XRND   			ay93
   AFDC-TOTAL-1994_REVISED_XRND   			ay94
   FDSTMPS-TOTAL-1993_REVISED_XRND			fy93
   FDSTMPS-TOTAL-1994_REVISED_XRND			fy94
   SSI-TOTAL-1993_REVISED_XRND    			siy93
   SSI-TOTAL-1994_REVISED_XRND    			siy94
   WELFARE-AMT-1993_REVISED_XRND  			wiyo93
   WELFARE-AMT-1994_REVISED_XRND  			wiyo94
   AFDC-TOTAL-1995_REVISED_XRND   			ay95
   AFDC-TOTAL-1996_REVISED_XRND   			ay96
   FDSTMPS-TOTAL-1995_REVISED_XRND			fy95
   FDSTMPS-TOTAL-1996_REVISED_XRND			fy96
   SSI-TOTAL-1995_REVISED_XRND    			siy95
   SSI-TOTAL-1996_REVISED_XRND    			siy96
   WELFARE-AMT-1995_REVISED_XRND  			wiyo95
   WELFARE-AMT-1996_REVISED_XRND  			wiyo96
   AFDC-TOTAL-1997_REVISED_XRND   			ay97
   AFDC-TOTAL-1998_REVISED_XRND   			ay98
   FDSTMPS-TOTAL-1997_REVISED_XRND			fy97
   FDSTMPS-TOTAL-1998_REVISED_XRND			fy98
   SSI-TOTAL-1997_REVISED_XRND    			siy97
   SSI-TOTAL-1998_REVISED_XRND    			siy98
   WELFARE-AMT-1997_REVISED_XRND  			wiyo97
   WELFARE-AMT-1998_REVISED_XRND  			wiyo98
   AFDC-TOTAL-1999_REVISED_XRND   			ay99
   AFDC-TOTAL-2000_REVISED_XRND   			ay100
   FDSTMPS-TOTAL-1999_REVISED_XRND			fy99
   FDSTMPS-TOTAL-2000_REVISED_XRND			fy100
   SSI-TOTAL-1999_REVISED_XRND    			siy99
   SSI-TOTAL-2000_REVISED_XRND    			siy100
   WELFARE-AMT-1999_REVISED_XRND  			wiyo99
   WELFARE-AMT-2000_REVISED_XRND  			wiyo100
   AFDC-TOTAL-2001_REVISED_XRND   			ay101
   AFDC-TOTAL-2002_REVISED_XRND   			ay102
   FDSTMPS-TOTAL-2001_REVISED_XRND			fy101
   FDSTMPS-TOTAL-2002_REVISED_XRND			fy102
   SSI-TOTAL-2001_REVISED_XRND    			siy101
   SSI-TOTAL-2002_REVISED_XRND    			siy102
   WELFARE-AMT-2001_REVISED_XRND  			wiyo101
   WELFARE-AMT-2002_REVISED_XRND  			wiyo102
   AFDC-TOTAL-2003_XRND           			ay103
   AFDC-TOTAL-2004_XRND           			ay104
   FDSTMPS-TOTAL-2003_XRND        			fy103
   FDSTMPS-TOTAL-2004_XRND        			fy104
   SSI-TOTAL-2003_XRND            			siy103
   SSI-TOTAL-2004_XRND            			siy104
   WELFARE-AMT-2003_XRND          			wiyo103
   WELFARE-AMT-2004_XRND          			wiyo104
   AFDC-TOTAL-2005_XRND           			ay105
   AFDC-TOTAL-2006_XRND           			ay106
   FDSTMPS-TOTAL-2005_XRND        			fy105
   FDSTMPS-TOTAL-2006_XRND        			fy106
   SSI-TOTAL-2005_XRND            			siy105
   SSI-TOTAL-2006_XRND            			siy106
   WELFARE-AMT-2005_XRND          			wiyo105
   WELFARE-AMT-2006_XRND          			wiyo106
   AFDC-TOTAL-2007_XRND           			ay107
   FDSTMPS-TOTAL-2007_XRND        			fy107
   SSI-TOTAL-2007_XRND            			siy107
   WELFARE-AMT-2007_XRND          			wiyo107
   AFDC-TOTAL-2008_XRND           			ay108
   FDSTMPS-TOTAL-2008_XRND        			fy108
   SSI-TOTAL-2008_XRND            			siy108
   WELFARE-AMT-2008_XRND          			wiyo108
   FDSTMPS-TOTAL-2009_XRND        			fy109
   SSI-TOTAL-2009_XRND            			siy109
   WELFARE-AMT-2009_XRND          			wiyo109
   AFDC-TOTAL-2009_XRND           			ay109
   AFDC-TOTAL-2010_XRND           			ay110
   FDSTMPS-TOTAL-2010_XRND        			fy110
   SSI-TOTAL-2010_XRND            			siy110
   WELFARE-AMT-2010_XRND          			wiyo110
   FDSTMPS-TOTAL-2011_XRND        			fy111
   WELFARE-AMT-2011_XRND          			wiyo111
   AFDC-TOTAL-2011_XRND           			ay111
   SSI-TOTAL-2011_XRND            			siy111
   AFDC-TOTAL-2012_XRND           			ay112
   FDSTMPS-TOTAL-2012_XRND        			fy112
   SSI-TOTAL-2012_XRND            			siy112
   WELFARE-AMT-2012_XRND          			wiyo112
   AFDC-TOTAL-2013_XRND           			ay113
   FDSTMPS-TOTAL-2013_XRND        			fy113
   SSI-TOTAL-2013_XRND            			siy113
   WELFARE-AMT-2013_XRND          			wiyo113
   AFDC-TOTAL-2014_XRND           			ay114
   FDSTMPS-TOTAL-2014_XRND        			fy114
   SSI-TOTAL-2014_XRND            			siy114
   WELFARE-AMT-2014_XRND          			wiyo114
   AFDC-TOTAL-2015_XRND           			ay115
   FDSTMPS-TOTAL-2015_XRND        			fy115
   SSI-TOTAL-2015_XRND            			siy115
   WELFARE-AMT-2015_XRND          			wiyo115
   AFDC-TOTAL-2016_XRND           			ay116
   AFDC-TOTAL-2017_XRND           			ay117
   FDSTMPS-TOTAL-2016_XRND        			fy116
   FDSTMPS-TOTAL-2017_XRND        			fy117
   SSI-TOTAL-2016_XRND            			siy116
   SSI-TOTAL-2017_XRND            			siy117
   WELFARE-AMT-2016_XRND          			wiyo116
   WELFARE-AMT-2017_XRND          			wiyo117
   AFDC-TOTAL-2018_XRND           			ay118
   AFDC-TOTAL-2019_XRND           			ay119
   FDSTMPS-TOTAL-2018_XRND        			fy118
   FDSTMPS-TOTAL-2019_XRND        			fy119
   SSI-TOTAL-2018_XRND            			siy118
   SSI-TOTAL-2019_XRND            			siy119
   WELFARE-AMT-2018_XRND          			wiyo118
   WELFARE-AMT-2019_XRND          			wiyo119
   AFDC-TOTAL-2020_XRND           			ay120
   AFDC-TOTAL-2021_XRND           			ay121
   FDSTMPS-TOTAL-2020_XRND        			fy120
   FDSTMPS-TOTAL-2021_XRND        			fy121
   SSI-TOTAL-2020_XRND            			siy120
   SSI-TOTAL-2021_XRND            			siy121
   WELFARE-AMT-2020_XRND          			wiyo120
   WELFARE-AMT-2021_XRND          			wiyo121
   AFDC-TOTAL-2022_XRND           			ay122
   AFDC-TOTAL-2023_XRND           			ay123
   FDSTMPS-TOTAL-2022_XRND        			fy122
   FDSTMPS-TOTAL-2023_XRND        			fy123
   SSI-TOTAL-2022_XRND            			siy122
   SSI-TOTAL-2023_XRND            			siy123
   
data Q13;
 set Q13a; 
 if intYr>0 then intYr=intYr-1900;
 
***** create afdc + food stamps + ssi as wiy( );
data two;
 merge one aupdate fupdate siupdate 
       R30.lintdate2022 (keep=norcid lIntYr lIntMo) Q13;
 by norcid;
 if aupdate=1 or fupdate=1 or siupdate=1;
 
array ay (*) ay78-ay123;
array fy (*) fy78-fy123;
array siy (*) siy78-siy123;
array wiy (*) wiy78-wiy123; 
do i=(lintyr-77) to (intyr-77);
 if ay(i)=-4 & siy(i)=-4 & fy(i)=-4 then wiy(i)=-4;
 else if ay(i) in (-1 -2 -3) or siy(i) in (-1 -2 -3) or fy(i) in (-1 -2 -3) then wiy(i)=-3;
 else wiy(i)=max(ay(i), 0)+max(siy(i), 0)+max(fy(i), 0);
end;

NLSY79 Appendix 14: Instrument Rosters

Instrument rosters

In the paper and pencil (PAPI) questionnaires administered from 1979-1992, basic information about specific types of subjects (household members, children, etc.) was often recorded in a table or grid structure, and subsequently stored in a similar format. With computer assisted personal interviewing (CAPI), expanded electronic versions of these grids and tables were implemented.

During the course of the survey, a number of these matrices of data, or "rosters," are constructed. Rosters contain one or more pieces of information on a given subject. They are often presented to the interviewers as lists of information that are used to verify information, or from which one of the subjects on the roster is chosen as the answer to a survey question. For example, the EMPLOYER roster (a list of employers for whom the employer has worked since the date of last interview), is presented to the interviewer at the end of the ON JOBS module of the survey, so that s/he can verify that the list of employers, and some specific information associated with each employer is accurate.

Many of the rosters used during the administration of the survey are not presented as contiguous blocks of data in the public release data. Often in these cases, the relevant information contained in these rosters is present in variables scattered throughout the public data. For instance, although the many variables found on the EMPLOYER roster are not present as a contiguous block, or a roster per se, much of the information contained in the roster is present in other variables in the Employer Supplements.

Occasionally, sets of created variables may also be loaded into a roster structure. The primary example of a roster constructed outside of a running survey is the EMPLOYER_HISTORY roster, which contains over 40,567 variables in the current public release data.

A number of commonly used rosters (or comparable grid items from the 1979-1992 PAPI questionnaires) are listed below, along with the formats of question names for those roster items, relevant areas of interest and helpful search criteria. Work continues on imposing more consistency on question names and substantive areas of interest, so users can expect to see improvements with each successive release. Changes will be reflected in accompanying documentation.

For further discussion of rosters, see Appendix 13: Intro to CAPI Questionnaires and Codebooks.

Household roster

The HHI_FINAL roster in the 1993-present electronic questionnaires replaced the Household Enumeration in the PAPI instruments from 1979-1992.

  • Relevant Areas of Interest = HOUSEHOLD RECORD
  • Roster Names for Survey Years 1979-Present = HHI_FINAL_[FIELDNAME]

Employer roster

The EMPLOYER roster did not exist in a cohesive fashion prior to 1993. However, most of the elements on this roster are included in a systematic fashion in the Employer Supplements sections for each survey year.

  • Areas of Interest include JOB INFORMATION; EARNINGS; INDUSTRY & OCCUPATION; TIME & TENURE W/EMPLOYER; PERIODS NOT WORKING WITHIN JOB TENURE; EMPLOYER LINKS; JOBS
  • Roster Names for Survey Years 1979-present = EMPLOYER_[FIELDNAME]

Roster of biological children

The FERTILITY AND RELATIONSHIP HISTORY/CREATED area of interest, survey year XRND, provide a cumulative and extensively reviewed record of biological children. These variables have been updated with each survey round and contain the latest information available for sex, birthdate, death date (if applicable) and latest residential status for each biological child. Researchers can use the following variables as an up-to-date cumulative roster of biological children:

  • C#DOB~M DATE OF BIRTH OF ## CHILD – MONTH
  • C#DOB~Y DATE OF BIRTH OF ## CHILD – YEAR
  • C#SEX SEX of ## CHILD
  • C#ID TWO-DIGIT ID OF ## CHILD
  • C#RES_DLI RESIDENCE OF ## CHILD AT DATE OF LAST INTERVIEW
  • C#DOD~M DATE OF DEATH OF ## CHILD – MONTH
  • C#DOD~Y DATE OF DEATH OF ## CHILD - YEAR

Non-biological child roster

The NBIOCHILD rosters in 1994-2014 replace the paper and pencil Non-biological Children's Record Form in the PAPI instruments from 1979-1992.

  • Relevant Areas of Interest = CHILD RECORD FORM/NONBIOLOGICAL
  • Roster Names for Survey Years 1979-1996 = NBIO[FIELDNAME]
  • Roster Names for Survey Years 1998-2012 = NBIOCHILD4_[FIELDNAME]
  • Roster Names for Survey Year 2014 = NBIOCHILD_[FIELDNAME]

Employer History roster

The EMPLOYER HISTORY roster was compiled and first released in a 2013 interim public release. This roster is compiled mainly from elements in the Employer Supplements and On Jobs sections for each survey year. It constructs a single record from the first report to the most recent stopdate given for each employer reported by a respondent, and includes many commonly used employer-associated variables. More information can be found at Appendix 28: NLSY79 Employer History Roster.

  • Areas of Interest include those beginning with EMPLOYER HISTORY – [SUBSTANTIVE CONTENT]
  • Roster Names for Survey Years 1979-present = EMPLOYERS_ALL_[FIELDNAME]

NLSY79 Appendix 13: Intro to CAPI Questionnaires and Codebooks

This appendix details the development of the NLSY79 questionnaires and codebooks.

In 1992 (round 14) and prior survey years, interviews were conducted by Paper and Pencil Interviewing (PAPI). Computer-Assisted Personal Interviewing (CAPI) technology was introduced in a small experiment in 1989 (round 11) and a larger experiment in 1990 (round 12). Round 15 (1993) marked the first round of the National Longitudinal Survey of Youth 1979 to be administered entirely using CAPI technology. Wherever possible, comparability was maintained between the 1993 data documentation and that of previous survey years. However, continuous innovations in technology and certain data collection procedures have resulted in considerable improvement in the format and content of electronic questionnaires and codebook documentation. A number of these transformations are outlined below.

Questionnaire innovations

Technological advancements in CAPI survey software have facilitated efficiencies in the conduct of interviews that were not possible with the PAPI instruments. Some significant advancements that accompanied the transition to CAPI data collection have included:

  • the availability of specialized question types, allowing for more precision in data entry and processing.
  • automated accessing of information reported earlier in the survey, eliminating the need for interviewers to search back through the questionnaire or keep track of earlier responses to reference them in later questions;
  • automated text substitutions ranging from inserting a name to large substantive texts that vary based on circumstance;
  • replacement of most hard-copy QxQ material with electronic help screens, linked to individual relevant questions;
  • imposition of minimums and maximums for many numeric questions, reducing the instances of erroneous outliers;
  • "bounded interviewing" - minimum/maximum values for dates, similar to those set for numeric questions; bounding of dates drastically reduces if not completely eliminates, anomalies such as job gap dates that precede the appropriate start date or exceed the appropriate stop dates, start dates that exceed interview dates, etc.
  • structured rostering of records pertaining to groups that are the subject of inquiry, such as employers, children, household members; the roster organizational structure provides more efficient storage of data related to the individual employers/children/etc., as well as clarity in presentation to the interviewer on the computer screen.
  • question loops: Loops are repeating sets of questions, asked about different subjects of inquiry. For example, series of similar or identical questions that need to be asked about each appropriate subject in a group (employer/child/household member/etc.) can be programmed in loops. The electronic instrument then cycles through these loops containing very similar or identical questions for each individual subject in the group. Loops reinforce the uniformity of data collection about each unit of observation in a group. Finally, question loops allow for expansion of the number of subjects or events in an event history that can be collected without adding potentially substantial volume or complication to a hard-copy questionnaire. In PAPI survey years, the number of columns available in the hard-copy questionnaires to collect information on subjects such as household members, children, gaps in employment, training programs, etc. were finite -- limited by space on the page. This limitation disappeared with the use of electronic questionnaires. This feature also allowed the expansion of the recipiency questions to a more extensive event history.
  • additional functionality of electronic questionnaires; Mechanical data checks that filter respondents into correct questions and the capability to sort individual subjects organized in a roster, combine with question loops to help ensure that questions are administered about the correct subjects in the correct order. For example, rostering and sorting ensure that the "current/most recent employer," referred to historically as the "CPS employer," is always asked about in the first loop of questions. Although this has always been the intention, recording and processing errors in PAPI years resulted in occasional cases for which the CPS employer was not entered as the first employer.

Data and documentation innovations

Continuing enhancements to CHRR's Designer CAPI software have made possible several more advancements in the presentation of data and documentation as well. These include:

  • increased uniformity in question naming conventions, improving the ability to identify comparable questions across survey rounds; In PAPI survey rounds (1979-1992) question names changed with each round. The evolution of Designer CAPI software also entailed several rounds of changes in question naming formats. CHRR personnel have been working as schedules and manpower allows, to eliminate question name inconsistencies resulting from these multiple transitions. This effort is on-going with additional progress reflected in each successive public release.
  • improvement in assignment of more precise areas of interest. Multiple areas of interest can be assigned to variables that make sense in more than one substantive category. In addition, areas of interest (particularly large and/or more generic ones) can be broken down into more precise and meaningful categorizations. Adjustments to area of interest assignments are part of an on-going effort, similar to that described above with respect to question naming.
  • greater ease in documentation capability. Vastly improved documentation features in the software have allowed sets of created variables of considerable size (Work History week-by-week arrays and the Employer History roster for example) to be incorporated into public release data sets relatively smoothly.

Continuing data and documentation enhancements

As noted above, changes in interviewing modes and rapid technological innovation led to some inconsistencies in documentation over the history of the survey. Many of these inconsistencies have arisen because of modifications in the conventions for question naming, assignment of areas of interest and formatting of various documentation components. CHRR personnel are working continually on updating documentation to increase comparability of documentation through survey years, and increase user-friendliness of the data and codebook.

Comparability in data presentation: "Consolidated" variables

An effort was been made in the 1979-1993 data release to maintain comparability with PAPI data releases in terms of data presentation. Toward this end, some sets of variables have been "consolidated." In other words, the responses for multiple variables are collapsed into a single created variable or set of variables. This has been done primarily for variables that in previous years were a single data item or set of data items, but are collected in more than one variable or set of variables in the CAPI questionnaires.

In each case, the variables being consolidated are mutually exclusive with respect to substantive responses. In other words, if variable A, variable B and variable C are consolidated, respondents will have given a response to only one of these - either variable A, or variable B or variable C.

Consolidation spares users from having to access a larger number of variables and use each separately or combine the responses themselves.

NLSY79 Appendix 12: Most Important Job Learning Activities (1993-94)

Respondents were asked in 1993 and in 1994 to identify the activities most important in helping them to learn how to perform their current or most recent job duties, and in helping them to learn about how work place changes would affect their jobs.

Most Important Job Learning Activities (1993) 

The 1993 data are contained in the following variables:

  • R41986. Most Important Activity To Learn Current/Most Recent Occupation (RE)
  • R41987. Prompt-Most Important Ac To Learn Current/Most Recent Occupation (RE)
  • R42641. Most Important Act To Learn How Wrkplc Chngs Would Affect Job
  • R42642. Prompt-Most Important Act To Learn How Wrkplc Chngs Would Affect Job?

These variables contain only codes. The substantive value labels for the codes are listed below:

Code

Value Labels

More than one activity mentioned as most important

2

Classes or seminars

3

Spending time with supervisors

4

Spending time with coworkers

5

Using self-teaching materials

6

Learning new skills on own

7

Trial and error

8

Previous job experience

9

On-the-job/hands on experience, learning by doing

10

Other

20

Reported only classes or seminars

30

Reported only spending time with supervisors

40

Reported only spending time with supervisors

50

Reported only self-teaching materials

60

Reported only learning new skills on own

Most Important Job Learning Activities (1994)

These data are contained in the following variables:

  • R45931. Most Important Activity To Learn Job #1 Occupation (RE)
  • R45932. Prompt-Most Important Ac To Learn Job #1 Occupation (RE)
  • R46372. Most Important Activity To Learn Job #2 Occupation (RE)
  • R46373. Prompt-Most Important Ac To Learn Job #2 Occupation (RE)
  • R46809. Most Important Activity To Learn Job #3 Occupation (RE)
  • R46810. Prompt-Most Important Ac To Learn Job #3 Occupation (RE)
  • R47195. Most Important Activity To Learn Job #4 Occupation (RE)
  • R47196. Prompt-Most Important Ac To Learn Job #4 Occupation (RE)
  • R47530. Most Important Activity To Learn Job #5 Occupation (RE)
  • R47531. Prompt-Most Important Ac To Learn Job #5 Occupation (RE)
  • R48046. Most Important Act To Learn How Wrkplc Chngs Would Affect Job
  • R48047. Prompt-Most Important Act To Learn How Wrkplc Chngs Would Affect Job?

These variables contain only codes. The substantive value labels for the codes are listed below:

Code

Value Labels

More than one activity mentioned as most important

2

Classes or seminars

3

Spending time with supervisors

4

Spending time with coworkers

5

Using self-teaching materials

6

Learning new skills on own

7

Trial and error

8

Previous job experience

9

On-the-job/hands on experience, learning by doing

10

Other

11

Classes/workshops/conferences

12

Practicing

13

Read journals/books/articles/viewed videos

14

Communicate with/observe experts/colleagues/peers

15

Self-taught/studying on own

16

Experience (unspecified)

20

Reported only classes or seminars

30

Reported only spending time with supervisors

40

Reported only spending time with supervisors

50

Reported only self-teaching materials

60

Reported only learning new skills on own

NLSY79 Appendix 11: Round 12 (1990) Survey Administration Methods

Round 12 of the NLSY79 survey incorporated a large-scale experiment involving comparison between PAPI (Paper and Pencil Interviewing) and CAPI (Computer-Assisted Personal Interviewing) methods of interviewing, in anticipation of a possible conversion to CAPI-only data collection in the future. An experimental control-group design was implemented during the fielding period for the 1990 survey, allowing the examination of possible mode effects, any differences in data quality between modes, as well as differences in time and cost factors of administration. The CAPI version of the instrument was designed to replicate the paper instrument, which reduced the efficiency of the CAPI instrument somewhat. More detailed information on the results of examinations of mode effects are available through CHRR. There are no indications that data quality was adversely affected by the experimental CAPI administration; indeed, the efficiency of data collection and data quality appear to have improved. Variables depicting interview modes in the 1990 data reflect respondents' assignments to various design groups at the outset of the survey as well as the mode actually used, allowing researchers to conduct their own methodologically-oriented examinations (see vars. R34003., R34004.).

NLSY79 Appendix 9: Linking Employers from OnJobs Section to Employer Supplement and Through Survey Years

This appendix contains several components:

  1. Descriptions of two critical employer-related questionnaire modules (the "OnJobs" module and Employer Supplements (ES) for each employer since the last interview) are presented
  2. Variables linking the ES data to data for the corresponding employer data from the OnJobs module are explained
  3. The process of linking employers between survey years is addressed
  4. User notes pertaining to NLSY79 employer-related data are included

For more information on these and other employer-related topics, consult the Jobs & Employers pages and Employment section of the NLSY79 Topical Guide.

Questionnaire modules

OnJobs module

In the OnJobs module, a list of employers for whom the respondent worked between the previous and current interviews is built (sorted most recent to least recent).

  • First, the list of employers with whom the respondent was active at the date of last interview ("DLI" employers) are verified and corrected if necessary.
  • Second, respondents are asked if they worked again for any employers they were associated with prior to the last interview ("PDLI" employers).
  • Third, respondents report any new employers ("NEW" employers) that are not on either the "DLI" or "PDLI" employer list.

The result is a complete list of employers for whom the respondent worked between the previous to current interview. If multiple employers were reported, the list is then sorted from most to least recent stopdate, creating the final list or "roster" of ES employers for the current interview.

Before the 1979-2018 data release, and particularly for respondents with multiple employers, researchers have not been able to definitively link information collected in the OnJobs module to specific employers in the ESs. Prior to 2002, data produced from the OnJobs modules was limited both in quantity and analytic utility. However, beginning in 2002, questions were added to the OnJobs modules to establish and verify a "job type" (traditional, non-traditional or self-employment) for each employer. Researchers have been interested in linking this more substantive information to specific ES employers. The 1979-2018 data release contains variables (described below) that make this possible.

Employer Supplements

An ES is administered for each employer on the final roster that results from the OnJobs module. Respondents are asked to provide extensive employer-related information related to each employer. This information varies through survey years. The final job type determined for each job is available in the ES for survey years 2002-2018. However, the questions used to establish the job type are not available in the ES. The current data release includes variables that allow researchers to link data in the OnJobs module and to the corresponding ESs. A description of these variables follows.

Variables linking OnJobs and Employer Supplement employer data

For the first time with the 2018 data release, the NLSY79 data includes several variables linking employer data collected in the OnJobs module with the corresponding ES.

  • DLILINK.## - contains DLI employer loop number in OnJobs module corresponding to ES ## (2002-2012). Qnames Q6-8[].## contain job type and verification data for DLI employers.
  • PDLILINK.## - contains PDLI employer loop number in OnJobs module corresponding to ES ## (2002-2012) Qnames Q6-16[].## contain job type and verification data for PDLI employers.
  • NEWLINK.## - contains NEW employer loop number in OnJobs module corresponding to ES ## (2002-2012). Qnames Q6-27[].## contain job type and verification data for NEW employers.
  • EMPLINK.## - contains loop number in OnJobs module corresponding to ES ## (2014-2018) (DLI, PDLI and NEW employer loops in OnJobs module were collapsed into one loop beginning in 2014)

Consider a respondent with the following characteristics and reflected in Table 1 below. At the 2008 interview, this respondent confirms two DLI employers and reports the stopdates in Table 1. S/he also reports returning to a PDLI employer for a period between the 2006 and 2008 interview, stopping work again on the date in Table 1. In addition, a NEW employer is reported with the stopdate in Table 1. Once these employers are confirmed, the job type questions would be asked in their entirety for newly added employers, or confirmed and updated if necessary, for employers for which a job type was previously established.

Table 1. Example: 2008 respondent OnJobs to Employer Supplement links
OnJobs Employers Reported Stopdates reported
Note 1.1
Employer Supplement Number Note 1.2 DLILINK.## PDLILINK.## NEWLINK.##
DLI emp #1 8/2007

4

DLILINK.04=1 PDLILINK.04=-4 NEWLINK.04=-4
DLI emp #2 11/2008

1

DLILINK.01=2 PDLILINK.01=-4 NEWLINK.01=-4
PDLI emp #1 8/2008

2

DLILINK.02=-4 PDLILINK.02=1 NEWLINK.02=-4
NEW emp #1 12/2007

3

DLILINK.03=-4 PDLILINK.03=-4 NEWLINK.03=1

Note: ## = Employer Supplement number.

Note 1.1: Final roster is sorted by stopdate

Note 1.2: After sorting final roster by stopdate

In the example in Table 1:

  • Data in OnJobs DLI employer #2 (DLI loop #2) corresponds to ES #1
  • Data in OnJobs PDLI employer #1 (PDLI loop #1) corresponds to ES #2
  • Data in OnJobs NEW employer #1 (NEW loop #1) corresponds to ES #3
  • Data in OnJobs DLI employer #1 (DLI loop #1) corresponds to ES #4

Process for linking jobs through survey years

Beginning in July 2013, the comprehensive "Employer History" roster has been made available to data users. This roster not only establishes links between employers through multiple survey years, but compiles a large amount of information about employers from one survey year to another into a single record for each employer. For further information about the Employer History roster, see Appendix 28: Employer History Roster.

It is still possible for users to link the respondents' employers from each contiguous survey year to the next using the traditional method. This appendix describes the traditional job linking process.

Comparable variables exist for each employer in all survey years, allowing a link to be established through all contiguous interview years during which the respondent reported working for a specific employer.

Use the variables with question names beginning with "PREV_EMP." All of these previous employer variables have a reference number that begins with "W." For example, the variables listed below in Table 2 relate to employers reported during the 1990 interview.

Table 2. Variables identifying job number assigned in previous interview
R Number Question Name Variable Title
W05057.00 PREV_EMP#_1990_JOB#01 PREVIOUS JOB NUMBER AT LAST INTERVIEW, JOB 1, 1990
W05058.00 PREV_EMP#_1990_JOB#02 PREVIOUS JOB NUMBER AT LAST INTERVIEW, JOB 2, 1990
W05059.00 PREV_EMP#_1990_JOB#03 PREVIOUS JOB NUMBER AT LAST INTERVIEW, JOB 3, 1990
W05060.00 PREV_EMP#_1990_JOB#04 PREVIOUS JOB NUMBER AT LAST INTERVIEW, JOB 4, 1990
W05061.00 PREV_EMP#_1990_JOB#05 PREVIOUS JOB NUMBER AT LAST INTERVIEW, JOB 5, 1990

These variables identify the number that a job was assigned in the previous interview year, if that job was reported. If these variables contain a valid missing code (-4), then the job was not reported in the previous interview year (1989) and therefore cannot be linked to any employer in the previous year. This is essentially a "new" employer, reported for the first time during the current survey year (or possibly an employer reported before the previous interview). If any of these variables contains a valid number (1 or greater), this is the number of that job in the previous interview year. For example, if W05057.00 contains a "2", this would mean that employer #1 in 1990 is the same employer as employer #2 from 1989. One could then attach information from employer #1 in 1990 to information from employer #2 in 1989 as a continuing record of the respondent's experience with that employer. Using corresponding variables through contiguous interview years, information for an employer can be traced back through the first time the employer was ever reported by the respondent.

Of course, forward linking of employers can be accomplished in much the same way, using the same set of Previous Employer variables. For instance, to link information about employer #2 in 1989 with its continuation in 1990, one would search the 1990 Previous Employer Number variables for the number "2." Thus, a "2" in variable W0505900 would indicate that employer #3 in 1990 is the continuation of employer #2 from 1989.

This procedure works through contiguous survey years, even if the respondent has skipped interviews and the survey years are not consecutive. For example, if a respondent was interviewed in all years from 1985-1990, a direct match can not be made between an employer reported in 1990 and one reported in 1985 without first establishing matches (or the lack thereof) through all intervening years. However if a respondent was interviewed in 1985, and not again until 1990, a link between employers reported in these two years would be accomplished in the same manner as that described above between 1989 and 1990, as there would be no intervening year(s) to interfere with a direct match.

Important information: Users should be aware of several data characteristics

First, the NLSY79 employment history data are employer based. All references to a "job" should be understood as a reference to an employer. Information about work duties and positions and/or changes in duties or position performed or held during the respondent's tenure with a specific employer is collected as part of the record for that specific employer. For example, a respondent may regard him/herself as having held a number of "jobs" or positions with employer #1. However, any information collected about these different positions would all be regarded as information about employer #1.

The data for many survey years contain multiple versions of the PREVIOUS JOB NUMBER variables for employer matching. However, the PREVIOUS JOB NUMBER variables are compiled as part of the Work History programming and (as signified by reference numbers beginning with "W" consolidate this information into a single item for each employer for each survey year. Examples of these for 1990 are listed above in Table 2.

In the course of creating the Employer History roster mentioned earlier, a new more comprehensive version of the unique id was created for each job ever reported. These variables are called "EMPLOYERS_ALL_UID." These new unique employer ids are present for all jobs reported by all respondents since 1979. While these ids will usually match the id described in the paragraph above, they will not always match. Users should consider using the EMPLOYERS_ALL_UID.## variables wherever necessary, as these will generally be more consistent and available for all jobs.

This unique identification number consists of the first survey year in which the employer was reported, appended with the employer number in that survey year multiplied by 100. So for instance, an employer first reported as employer #1 in 1993 would have a unique employer id of 19930100. An employer first reported as employer #3 in 1994 would have the unique employer id of 19940300, and so on. This id number stays with the employer in subsequent survey rounds, whether or not more information is added to the employer record.

Users should note that previous versions of "unique ids" for employers were only available for respondents still eligible for interview in 1996 and subsequent survey years.

NLSY79 Appendix 8: Highest Grade Completed, Enrollment Status Variable Creation & Highest Degree Ever Reported

Highest Grade Completed & Enrollment Status variable creation

Data releases since 2018 have included a created variable depicting the Highest Grade Ever Completed (HGC_EVER), found in the ”Key Variables” and “School” areas of interest. This XRND variable incorporates information through the respondent's most recent interview and will be updated for each round in which relevant questions are asked. The program that created this variable is accessible through a link at the end of this appendix.

The Highest Grade Completed variables for individual survey years are available from 1979-2016. The program used to create the most recent Highest Grade Completed (HGCREV) and Enrollment Status (ENROLLMTREV) as of May 1st is accessible through a link at the end of this appendix. Whenever possible, HGCREV variables have been adjusted for apparent reversals in grade and academic degree, so that the respondent’s highest grade completed during their lifetime is accurately reflected.

Highest Degree Ever Reported variable creation

A created variable depicting the Highest Degree Ever Reported (HIGHEST_DEGREE_EVER), has been added in the 2022 (round 30) data release. This XRND variable can be found in the KEY VARIABLES and DEGREES & CERTIFICATES areas of interest. HIGHEST_DEGREE_EVER incorporates information through the respondent's most recent interview. It will be updated for each future round in which relevant questions are asked. The program that created this variable is accessible through a link at the end of this appendix.

Users should note that in some cases, the HIGHEST_DEGREE_EVER will not necessarily match the traditional HGC_EVER. For instance, a respondent might report an Associate’s level degree, but 13 or 16 years of school, instead of the traditional 14. Or a respondent might report a bachelor’s degree for HIGHEST_DEGREE_EVER but have 17 or 18 years coded as HGC_EVER. This can be due several issues, including:

  • Over many years, there can be occasional inconsistencies in respondent reports of the highest grade they have completed, and/or the highest degree they report. This could be due to many factors, from respondent memory or misreporting, to data entry errors.
  • The highest grade completed may have been equated in some respondents’ minds as “years of school” rather than actual grade completed. For example, a respondent may have taken several more years to earn what used to be considered a traditional four-year bachelors degree, or multiple bachelors degrees. One might report a bachelor’s degree as HIGHEST_DEGREE_EVER, yet report 17 or 18 years as HGC_EVER. Many circumstances can lead to someone taking additional time to earn different types of degrees.

Every effort has been made to adjudicate discrepancies when possible, over the entirety of the respondent’s responses across survey years when constructing HGC_EVER and HIGHEST_DEGREE_EVER. Only academically ranked degrees are represented in HIGHEST_DEGREE_EVER. “Other” types of degrees for which not possible to determine an academic degree were superseded by the highest academic degree reported (high school diploma, associate’s degree, bachelor’s degree, etc.). In the absence of extreme inconsistencies in reports over time, the default HGC_EVER assigned to respondents reporting a high school diploma or ged is 12.

Program statements

Programs that create the XRND variables HGC_EVER and HIGHEST_DEGREE_EVER and the survey year HGCREV and ENROLLMTREV variables can be accessed by clicking below:

HIGHEST GRADE EVER COMPLETED as of Most Recent Interview

hgcrev20 = -4;
if (q3_4_2020 = -5) then hgcrev20 = -5;
else if (q3_1_2020 = 1 & q3_4_2020 >= 12 & q3_4_2020 < 95) then hgcrev20 = q3_4_2020;
else if (q3_1_2020 = 1 & q3_7_2020 = 1 & q3_4_2020 < 12) then hgcrev20 = 12;
else if (q3_1_2020 = 1 & q3_4_2020 > 0 & q3_4_2020 < 12) then hgcrev20 = q3_4_2020;
else if (q3_1_2020 = 1 & q3_4_2020 = 95) then hgcrev20 = -3;
else if (q3_1_2020 = 0 & hgc_ever_xrnd > -4) then hgcrev20 = hgc_ever_xrnd;
else if (q3_1_2020 = 0 & hgcrev16c > -4) then hgcrev20 = hgcrev16c;
else if (q3_1_2020 = 0 & hgcrev14c > -4) then hgcrev20 = hgcrev14c;
else if (q3_1_2020 = 0 & hgcrev12c > -4) then hgcrev20 = hgcrev12c;
else if (q3_1_2020 = 0 & hgcrev10c > -4) then hgcrev20 = hgcrev10c;
else if (q3_1_2020 = 0 & hgcrev08c > -4) then hgcrev20 = hgcrev08c;
else if (q3_1_2020 = 0 & hgcrev06c > -4) then hgcrev20 = hgcrev06c;
else if (q3_1_2020 = 0 & hgcrev04c > -4) then hgcrev20 = hgcrev04c;
else if (q3_1_2020 = 0 & hgcrev02c > -4) then hgcrev20 = hgcrev02c;
else if (q3_1_2020 = 0 & hgcrev00c > -4) then hgcrev20 = hgcrev00c;
else if (q3_1_2020 = 0 & hgcrev98c > -4) then hgcrev20 = hgcrev98c;
else if (q3_1_2020 = 0 & hgcrev96c > -4) then hgcrev20 = hgcrev96c;
else if (q3_1_2020 = 0 & hgcrev94c > -4) then hgcrev20 = hgcrev94c;
else if (q3_1_2020 = 0 & hgcrev93c > -4) then hgcrev20 = hgcrev93c;
else if (q3_1_2020 = 0 & hgcrev92c > -4) then hgcrev20 = hgcrev92c;
else if (q3_1_2020 = 0 & hgcrev91c > -4) then hgcrev20 = hgcrev91c;
else if (q3_1_2020 = 0 & hgcrev90c > -4) then hgcrev20 = hgcrev90c;
else if (q3_1_2020 = 0 & hgcrev89c > -4) then hgcrev20 = hgcrev89c;
else if (q3_1_2020 = 0 & hgcrev88c > -4) then hgcrev20 = hgcrev88c;
else if (q3_1_2020 = 0 & hgcrev87c > -4) then hgcrev20 = hgcrev87c;
else if (q3_1_2020 = 0 & hgcrev86c > -4) then hgcrev20 = hgcrev86c;
else if (q3_1_2020 = 0 & hgcrev85c > -4) then hgcrev20 = hgcrev85c;
else if (q3_1_2020 = 0 & hgcrev84c > -4) then hgcrev20 = hgcrev84c;
else if (q3_1_2020 = 0 & hgcrev83c > -4) then hgcrev20 = hgcrev83c;
else if (q3_1_2020 = 0 & hgcrev82c > -4) then hgcrev20 = hgcrev82c;
else if (q3_1_2020 = 0 & hgcrev81c > -4) then hgcrev20 = hgcrev81c;
else if (q3_1_2020 = 0 & hgcrev80c > -4) then hgcrev20 = hgcrev80c;
else if (q3_1_2020 = 0 & hgcrev79c > -4) then hgcrev20 = hgcrev79c;

hgc_ever=-4;
if (hgcrev20 > -4) then hgc_ever = hgcrev20;
else if (hgc_ever_xrnd > -4) then hgc_ever = hgc_ever_xrnd; /* hgc_ever is best info thru dli - so use as dli hgc */
else if (hgcrev16c > -4) then hgc_ever = hgcrev16c;
else if (hgcrev14c > -4) then hgc_ever = hgcrev14c;
else if (hgcrev12c > -4) then hgc_ever = hgcrev12c;
else if (hgcrev10c > -4) then hgc_ever = hgcrev10c;
else if (hgcrev08c > -4) then hgc_ever = hgcrev08c;
else if (hgcrev06c > -4) then hgc_ever = hgcrev06c;
else if (hgcrev04c > -4) then hgc_ever = hgcrev04c;
else if (hgcrev02c > -4) then hgc_ever = hgcrev02c;
else if (hgcrev00c > -4) then hgc_ever = hgcrev00c;
else if (hgcrev98c > -4) then hgc_ever = hgcrev98c;
else if (hgcrev96c > -4) then hgc_ever = hgcrev96c;
else if (hgcrev94c > -4) then hgc_ever = hgcrev94c;
else if (hgcrev93c > -4) then hgc_ever = hgcrev93c;
else if (hgcrev92c > -4) then hgc_ever = hgcrev92c;
else if (hgcrev91c > -4) then hgc_ever = hgcrev91c;
else if (hgcrev90c > -4) then hgc_ever = hgcrev90c;
else if (hgcrev89c > -4) then hgc_ever = hgcrev89c;
else if (hgcrev88c > -4) then hgc_ever = hgcrev88c;
else if (hgcrev87c > -4) then hgc_ever = hgcrev87c;
else if (hgcrev86c > -4) then hgc_ever = hgcrev86c;
else if (hgcrev85c > -4) then hgc_ever = hgcrev85c;
else if (hgcrev84c > -4) then hgc_ever = hgcrev84c;
else if (hgcrev83c > -4) then hgc_ever = hgcrev83c;
else if (hgcrev82c > -4) then hgc_ever = hgcrev82c;
else if (hgcrev81c > -4) then hgc_ever = hgcrev81c;
else if (hgcrev80c > -4) then hgc_ever = hgcrev80c;
else if (hgcrev79c > -4) then hgc_ever = hgcrev79c;

HIGHEST GRADE COMPLETED as of May 1, 2016

* Create all the necessary arrays;

array weightA  (*) weight79 - weight94 weight96 weight98 weight00 weight02 weight04 weight06 weight08 weight10 weight12 weight14 ;
array intMoA   (*) intMo79 - intMo94 intMo96 intMo98 intMo00 intMo02 intMo04 intMo06 intMo08 intMo10 intMo12 intMo14 ;
array dleMoA   (*) dleMo79 - dleMo94 dleMo96 dleMo98 dleMo00 dleMo02 dleMo04 dleMo06 dleMo08 dleMo10 dleMo12 dleMo14 ;
array dleYrA   (*) dleYr79 - dleYr94 dleYr96 dleYr98 dleYr00 dleYr02 dleYr04 dleYr06 dleYr08 dleYr10 dleYr12 dleYr14 ;
array curAtA   (*) curAt79 - curAt94 curAt96 curAt98 curAt00 curAt02 curAt04 curAt06 curAt08 curAt10 curAt12 curAt14 ;
array hgcSA    (*) hgcS79 - hgcS94 hgcS96 hgcS98 hgcS00 hgcS02 hgcS04 hgcS06 hgcS08 hgcS10 hgcS12 hgcS14 ;
array hgcA     (*) hgc79 - hgc94 hgc96 hgc98 hgc00 hgc02 hgc04 hgc06 hgc08 hgc10 hgc12 hgc14 ;
array dipA     (*) dip79 - dip94 dip96 dip98 dip00 dip02 dip04 dip06 dip08 dip10 dip12 dip14 ;
array intYrA   (*) intYr79 - intYr94 intYr96 intYr98 intYr00 intYr02 intYr04 intYr06 intYr08 intYr10 intYr12 intYr14 ;


do i=1 to 15;
    if weightA(i)>0 then intYrA(i) = 1978+i;
end;


array mayA (26) _TEMPORARY_ (5 17 29 41 53 65 77 89 101 113 125 137 149 161 173 185 209 233 257 281 305 329 353 377 401 425);
array intA (*)                  int79 - int94 int96 int98 int00 int02 int04 int06 int08 int10 int12 int14 ;
array dleA (*)                  dle79 - dle94 dle96 dle98 dle00 dle02 dle04 dle06 dle08 dle10 dle12 dle14 ;

hgc_cur=-4;             *current highest grade completed;

do i=1 to dim (mayA);
    if intMoA(i)>0 & intYrA(i)>0 then intA(i)=12*(intYrA(i)-1979)+intMoA(i);
    else if weightA(i)=0 then intA(i)=-5; 
     if dleMoA(i)>0 & dleYrA(i)>0 then dleA(i)=12*(dleYrA(i)-1979)+dleMoA(i);
      else if weightA(i)=0 then dleA(i)=-5;
      else if -4<dleMoA(i)<0 or -4<dleYrA(i)<0 then dleA(i)=-3;
      else dleA(i)=-4; 
end;

*-------------------------------------------------------------------------------;
* Set HGC(i) and HGCS(i) to -5 if Weight = 0 ;

do i = 2 to dim(hgcA);
    if (weightA(i) = 0) then do;
        hgcA(i) = -5;
        hgcsA(i) = -5;
    end;
end;

*-------------------------------------------------------------------------------;
* Sometimes, set hgc_cur to hgcs(i) or hgc(i);

    if  (asli_cur = 0 and                    /* did not attend school since last interview */
        flag16 = 1) then do i = dim(hgcA) to 1 by -1;

        if (hgc_cur = -4 and weightA(i) > 0) then do; /* Highest Grade completed current */
                          if ( IntA(i) >= mayA(i) and                   /* Interviewed in May+ */
                (CurAtA(i) = 1 or DLEA(i) >= mayA(i)) and /* Currently in school or was in school after May */
                 HgcSA(i) > HgcA(i) )
                then hgc_cur = HgcSA(i);    /* Highest grade completed*/
                else hgc_cur = HgcA(i);        /* Created HGC as of 05/01 survey year revised version*/
        end;
    end;


*-------------------------------------------------------------------------------;

if (asli_cur = 1 and flag16 = 1) then do;
    if (hgcs_cur <= 0)  then do;
        if (curat_c = 1 and grade_c >= 1) then hgc_cur=(grade_c - 1);
        else if (curat_c = 0 and hga_cur >= 1) then do;
            if (dleyr_ca < curantYr) or (dleyr_ca=curantYr and dlemo_ca < 5) then
                hgc_cur=hga_cur;
        end;
            else if hga_cur>0 then hgc_cur=(hga_cur - 1);
    end;
    else if ((hgcs_cur = hga_cur or hgcs_cur = grade_c))  then do;
            if ((dleyr_ca>curantyr) or (dleyr_ca = curantyr and dlemo_ca >= 5) or (curat_c = 1))  then
            hgc_cur=(hgcs_cur - 1);          
         else hgc_cur=hgcs_cur;
    end;
    else if ((hgcs_cur = (hga_cur-1)) or
             (hgcs_cur = (grade_c-1)) or
        (hgcs_cur < hga_cur and 0 < hga_cur <= 20) or
             (hgcs_cur < grade_c and 0 < grade_c <= 20)) then
               hgc_cur=hgcs_cur;
end;

*-------------------------------------------------------------------------------;

if ( ((hgc_cur = 10 or hgc_cur = 11) and (hvdip_c = 1 or attcol_c = 1)) or
     (dip_cur>=1 and hgc_cur < 12) or
     (hgc_cur = -4 and (dip_cur = 1 or dip_cur = 3))) then
      hgc_cur=12;
else if (hgc_cur < 0 and dip_cur = -3) then
      hgc_cur=-3;
*-------------------------------------------------------------------------------;

if ( (hgc_cur > 20) or
     (hgc_cur > hgc_dli + 3 & hgc_dli > 0 & dip_cur ~= 2 & dip_cur ~= 3) or
     (hgc_cur = 11 & hgc_dli = 12 )) then 
     hgc_cur=-3;   

*-------------------------------------------------------------------------------;

tru=0;          * true: 0 - does not have HS diploma (ever), 1 does have a HS diploma; 

do i = 1 to dim(dipA);
    *if (dipA(i) > 1) then do;
    if (dipA(i) > =1) then do;
        tru=1;
        if (hgc_cur < 12) then hgc_cur=12;               * has HS diploma => has HGC >= 12;
        leave; 
    end;
end;

*-------------------------------------------------------------------------------;

if (flag16 = 0) then do;
    hgc_cur=-5; 
    hgcRev_cur=-5;
end;

if (flag16 = 1) then do;
    if (hgc_cur = -4) then hgc_cur=-3;
end;

/* ----------------------------------------------------------------------- */

* ============================================;
*                                                                                              ;
* Create revised variables                                                      ;
*                                                                                              ;
* ============================================;
/* 
The revised variables take into account more accurately past reports of HGC to 
eliminate regressive changes in HGC (for instance, preventing someone who has 
previously reported completing 18 years of schooling, and is now working on an 
undergraduate level in some area from being coded lower than 18) */

/* maxGrd - the highest hgc value ever computed */

maxGrd=hgc_cur;
do i = 1 to dim(hgcA);
    if (weightA(i) > 0 & hgcA(i) > maxGrd) then  maxGrd = hgcA(i);
end;

if (hgc_cur = -5) then maxGrd = -5;

 

 

array weightA  (*) weight79 - weight94 weight96 weight98 weight00 weight02 weight04 weight06 weight08 weight10 weight12 weight14 ;

array intMoA   (*) intMo79 - intMo94 intMo96 intMo98 intMo00 intMo02 intMo04 intMo06 intMo08 intMo10 intMo12 intMo14 ;

array dleMoA   (*) dleMo79 - dleMo94 dleMo96 dleMo98 dleMo00 dleMo02 dleMo04 dleMo06 dleMo08 dleMo10 dleMo12 dleMo14 ;

array dleYrA   (*) dleYr79 - dleYr94 dleYr96 dleYr98 dleYr00 dleYr02 dleYr04 dleYr06 dleYr08 dleYr10 dleYr12 dleYr14 ;

array curAtA   (*) curAt79 - curAt94 curAt96 curAt98 curAt00 curAt02 curAt04 curAt06 curAt08 curAt10 curAt12 curAt14 ;

array hgcSA    (*) hgcS79 - hgcS94 hgcS96 hgcS98 hgcS00 hgcS02 hgcS04 hgcS06 hgcS08 hgcS10 hgcS12 hgcS14 ;

array hgcA     (*) hgc79 - hgc94 hgc96 hgc98 hgc00 hgc02 hgc04 hgc06 hgc08 hgc10 hgc12 hgc14 ;

array dipA     (*) dip79 - dip94 dip96 dip98 dip00 dip02 dip04 dip06 dip08 dip10 dip12 dip14 ;

array intYrA   (*) intYr79 - intYr94 intYr96 intYr98 intYr00 intYr02 intYr04 intYr06 intYr08 intYr10 intYr12 intYr14 ;

 

do i=1 to 15;

    if weightA(i)>0 then intYrA(i) = 1978+i;

end;

 

array mayA (26) _TEMPORARY_ (5 17 29 41 53 65 77 89 101 113 125 137 149 161 173 185 209 233 257 281 305 329 353 377 401 425);

array intA (*)                                                          int79 - int94 int96 int98 int00 int02 int04 int06 int08 int10 int12 int14 ;

array dleA (*)                                                         dle79 - dle94 dle96 dle98 dle00 dle02 dle04 dle06 dle08 dle10 dle12 dle14 ;

 

hgc_cur=-4;             *current highest grade completed;

 

do i=1 to dim (mayA);

                if intMoA(i)>0 & intYrA(i)>0 then intA(i)=12*(intYrA(i)-1979)+intMoA(i);

                else if weightA(i)=0 then intA(i)=-5;

                if dleMoA(i)>0 & dleYrA(i)>0 then dleA(i)=12*(dleYrA(i)-1979)+dleMoA(i);

                else if weightA(i)=0 then dleA(i)=-5;

                else if -4<dleMoA(i)<0 or -4<dleYrA(i)<0 then dleA(i)=-3;

                else dleA(i)=-4;

end;

 

*-------------------------------------------------------------------------------;

* Set HGC(i) and HGCS(i) to -5 if Weight = 0 ;

 

do i = 2 to dim(hgcA);

    if (weightA(i) = 0) then do;

        hgcA(i) = -5;

        hgcsA(i) = -5;

    end;

end;

 

*-------------------------------------------------------------------------------;

* Sometimes, set hgc_cur to hgcs(i) or hgc(i);

 

    if  (asli_cur = 0 and                    /* did not attend school since last interview */

        flag16 = 1) then do i = dim(hgcA) to 1 by -1;

 

        if (hgc_cur = -4 and weightA(i) > 0) then do; /* Highest Grade completed current */

                          if ( IntA(i) >= mayA(i) and                   /* Interviewed in May+ */

                (CurAtA(i) = 1 or DLEA(i) >= mayA(i)) and /* Currently in school or was in school after May */

                 HgcSA(i) > HgcA(i) )

                then hgc_cur = HgcSA(i);/* Highest grade completed*/

                else hgc_cur = HgcA(i);                    /* Created HGC as of 05/01 survey year revised version*/

        end;

    end;

 

*-------------------------------------------------------------------------------;

 

if (asli_cur = 1 and flag16 = 1) then do;

    if (hgcs_cur <= 0)  then do;

        if (curat_c = 1 and grade_c >= 1) then hgc_cur=(grade_c - 1);

        else if (curat_c = 0 and hga_cur >= 1) then do;

                                                if (dleyr_ca < curantYr) or (dleyr_ca=curantYr and dlemo_ca < 5) then

                hgc_cur=hga_cur;

        end;

               else if hga_cur>0 then hgc_cur=(hga_cur - 1);

    end;

    else if ((hgcs_cur = hga_cur or hgcs_cur = grade_c))  then do;

            if ((dleyr_ca>curantyr) or (dleyr_ca = curantyr and dlemo_ca >= 5) or (curat_c = 1))  then

            hgc_cur=(hgcs_cur - 1);         

         else hgc_cur=hgcs_cur;

    end;

    else if ((hgcs_cur = (hga_cur-1)) or

             (hgcs_cur = (grade_c-1)) or

                    (hgcs_cur < hga_cur and 0 < hga_cur <= 20) or

             (hgcs_cur < grade_c and 0 < grade_c <= 20)) then

                 hgc_cur=hgcs_cur;

end;

 

*-------------------------------------------------------------------------------;

 

if ( ((hgc_cur = 10 or hgc_cur = 11) and (hvdip_c = 1 or attcol_c = 1)) or

                 (dip_cur>=1 and hgc_cur < 12) or

     (hgc_cur = -4 and (dip_cur = 1 or dip_cur = 3))) then

      hgc_cur=12;

else if (hgc_cur < 0 and dip_cur = -3) then

      hgc_cur=-3;

*-------------------------------------------------------------------------------;

 

if ( (hgc_cur > 20) or

     (hgc_cur > hgc_dli + 3 & hgc_dli > 0 & dip_cur ~= 2 & dip_cur ~= 3) or

     (hgc_cur = 11 & hgc_dli = 12 )) then

                 hgc_cur=-3;  

 

*-------------------------------------------------------------------------------;

 

tru=0;          * true: 0 - does not have HS diploma (ever), 1 does have a HS diploma;

 

do i = 1 to dim(dipA);

    *if (dipA(i) > 1) then do;

                if (dipA(i) > =1) then do;

        tru=1;

        if (hgc_cur < 12) then hgc_cur=12;               * has HS diploma => has HGC >= 12;

        leave;

    end;

end;

 

*-------------------------------------------------------------------------------;

 

if (flag16 = 0) then do;

    hgc_cur=-5;

    hgcRev_cur=-5;

end;

 

if (flag16 = 1) then do;

    if (hgc_cur = -4) then hgc_cur=-3;

end;

 

/* ----------------------------------------------------------------------- */

 

* ============================================;

*                                                                                              ;

* Create revised variables                                                      ;

*                                                                                              ;

* ============================================;

/*

The revised variables take into account more accurately past reports of HGC to

eliminate regressive changes in HGC (for instance, preventing someone who has

previously reported completing 18 years of schooling, and is now working on an

undergraduate level in some area from being coded lower than 18) */

 

/* maxGrd - the highest hgc value ever computed */

 

maxGrd=hgc_cur;

do i = 1 to dim(hgcA);

    if (weightA(i) > 0 & hgcA(i) > maxGrd) then  maxGrd = hgcA(i);

end;

 

if (hgc_cur = -5) then maxGrd = -5;

 

hgcRev_cur = maxGrd;

HIGHEST DEGREE EVER COMPLETED as of Most Recent Interview

/**Variable Names in program    Variable Names in data release**/
PUBID                               CASEID                    
Q3-4_1979                           Q3_4_1979                 
Q3-8_1979                           Q3_8_1979                 
Q3-8A_1979                          Q3_8A_1979                
Q3-8C_M_1979                        Q3_8C_M_1979              
Q3-8C_Y_1979                        Q3_8C_Y_1979              
MIL-56A_1979                        MIL_56A_1979              
MIL-56B_1979                        MIL_56B_1979              
MIL-57A_1979                        MIL_57A_1979              
MIL-57B_1979                        MIL_57B_1979              
MIL-62A_1979                        MIL_62A_1979              
MIL-62B_1979                        MIL_62B_1979              
CPS-27B_1979                        CPS_27B_1979              
TRN-8_1979                          TRN_8_1979                
TRN-8A_1_1979                       TRN_8A_1_1979             
TRN-8A_2_1979                       TRN_8A_2_1979             
TRN-8A_3_1979                       TRN_8A_3_1979             
TRN-8A_4_1979                       TRN_8A_4_1979             
TRN-8B_1_1979                       TRN_8B_1_1979             
TRN-8B_2_1979                       TRN_8B_2_1979             
TRN-8B_3_1979                       TRN_8B_3_1979             
TRN-8B_4_1979                       TRN_8B_4_1979             
TRN-8C_1_1979                       TRN_8C_1_1979             
TRN-8C_2_1979                       TRN_8C_2_1979             
TRN-8C_3_1979                       TRN_8C_3_1979             
TRN-8C_4_1979                       TRN_8C_4_1979             
TRN-8D_1_1979                       TRN_8D_1_1979             
TRN-8D_2_1979                       TRN_8D_2_1979             
TRN-8D_3_1979                       TRN_8D_3_1979             
TRN-8D_4_1979                       TRN_8D_4_1979             
TRN-8E_1_M_1979                     TRN_8E_1_M_1979           
TRN-8E_1_Y_1979                     TRN_8E_1_Y_1979           
TRN-8E_2_M_1979                     TRN_8E_2_M_1979           
TRN-8E_2_Y_1979                     TRN_8E_2_Y_1979           
TRN-8E_3_M_1979                     TRN_8E_3_M_1979           
TRN-8E_3_Y_1979                     TRN_8E_3_Y_1979           
TRN-8E_4_M_1979                     TRN_8E_4_M_1979           
TRN-8E_4_Y_1979                     TRN_8E_4_Y_1979           
TRN-8F_1_1979                       TRN_8F_1_1979             
TRN-8F_2_1979                       TRN_8F_2_1979             
TRN-8F_3_1979                       TRN_8F_3_1979             
TRN-8F_4_1979                       TRN_8F_4_1979             
TRN-9_1979                          TRN_9_1979                
HGCREV79_1979                       HGCREV79_1979             
Q3-1_1980                           Q3_1_1980                 
Q3-4_1980                           Q3_4_1980                 
Q3-7_1980                           Q3_7_1980                 
Q3-8_1980                           Q3_8_1980                 
Q3-8A_1980                          Q3_8A_1980                
Q3-8C_M_1980                        Q3_8C_M_1980              
Q3-8C_Y_1980                        Q3_8C_Y_1980              
MIL-56_1980                         MIL_56_1980               
MIL-57_1980                         MIL_57_1980               
MIL-56A_1980                        MIL_56A_1980              
MIL-57A_1980                        MIL_57A_1980              
MIL-62_1980                         MIL_62_1980               
CPS-27B_1980                        CPS_27B_1980              
Q3-10A_1980                         Q3_10A_1980               
DEGREE-1A_1_1980                    DEGREE_1A_1_1980          
DEGREE-1B_1_1980                    DEGREE_1B_1_1980          
DEGREE-1C_1_1980                    DEGREE_1C_1_1980          
DEGREE-1D_1_1980                    DEGREE_1D_1_1980          
DEGREE-1E_1_M_1980                  DEGREE_1E_1_M_1980        
DEGREE-1E_1_Y_1980                  DEGREE_1E_1_Y_1980        
DEGREE-1F_1_1980                    DEGREE_1F_1_1980          
DEGREE-1A_2_1980                    DEGREE_1A_2_1980          
DEGREE-1B_2_1980                    DEGREE_1B_2_1980          
DEGREE-1C_2_1980                    DEGREE_1C_2_1980          
DEGREE-1D_2_1980                    DEGREE_1D_2_1980          
DEGREE-1E_2_M_1980                  DEGREE_1E_2_M_1980        
DEGREE-1E_2_Y_1980                  DEGREE_1E_2_Y_1980        
DEGREE-1F_2_1980                    DEGREE_1F_2_1980          
DEGREE-2_1980                       DEGREE_2_1980             
HGCREV80_1980                       HGCREV80_1980             
Q3-1_1981                           Q3_1_1981                 
Q3-4_1981                           Q3_4_1981                 
Q3-7_1981                           Q3_7_1981                 
Q3-8_1981                           Q3_8_1981                 
Q3-8A_1981                          Q3_8A_1981                
Q3-8C_M_1981                        Q3_8C_M_1981              
Q3-8C_Y_1981                        Q3_8C_Y_1981              
Q3-10A_1981                         Q3_10A_1981               
DEGREE-1A_1_1981                    DEGREE_1A_1_1981          
SCHOOL-33_1981                      SCHOOL_33_1981            
DEGREE-1A_2_1981                    DEGREE_1A_2_1981          
DEGREE-2_1981                       DEGREE_2_1981             
MIL-56_1981                         MIL_56_1981               
MIL-57_1981                         MIL_57_1981               
MIL-56A_1981                        MIL_56A_1981              
MIL-57A_1981                        MIL_57A_1981              
MIL-62_1981                         MIL_62_1981               
HGCREV81_1981                       HGCREV81_1981             
Q3-1_1982                           Q3_1_1982                 
Q3-4_1982                           Q3_4_1982                 
Q3-7_1982                           Q3_7_1982                 
Q3-8_1982                           Q3_8_1982                 
Q3-8A_1982                          Q3_8A_1982                
Q3-8C_M_1982                        Q3_8C_M_1982              
Q3-8C_Y_1982                        Q3_8C_Y_1982              
Q3-10A_1982                         Q3_10A_1982               
DEGREE-1A_1_1982                    DEGREE_1A_1_1982          
SCHOOL-33_1982                      SCHOOL_33_1982            
DEGREE-1A_2_1982                    DEGREE_1A_2_1982          
DEGREE-2_1982                       DEGREE_2_1982             
MIL-56_1982                         MIL_56_1982               
MIL-57_1982                         MIL_57_1982               
MIL-56A_1982                        MIL_56A_1982              
MIL-57A_1982                        MIL_57A_1982              
MIL-62_1982                         MIL_62_1982               
HGCREV82_1982                       HGCREV82_1982             
Q3-1_1983                           Q3_1_1983                 
Q3-4_1983                           Q3_4_1983                 
Q3-7_1983                           Q3_7_1983                 
Q3-8_1983                           Q3_8_1983                 
Q3-8A_1983                          Q3_8A_1983                
Q3-8C_M_1983                        Q3_8C_M_1983              
Q3-8C_Y_1983                        Q3_8C_Y_1983              
Q3-10A_1983                         Q3_10A_1983               
DEGREE-1A_1_1983                    DEGREE_1A_1_1983          
SCHOOL-33_1983                      SCHOOL_33_1983            
DEGREE-1A_2_1983                    DEGREE_1A_2_1983          
DEGREE-2_1983                       DEGREE_2_1983             
MIL-56_1983                         MIL_56_1983               
MIL-57_1983                         MIL_57_1983               
MIL-56A_1983                        MIL_56A_1983              
MIL-57A_1983                        MIL_57A_1983              
MIL-62_1983                         MIL_62_1983               
HGCREV83_1983                       HGCREV83_1983             
Q3-1_1984                           Q3_1_1984                 
Q3-4_1984                           Q3_4_1984                 
Q3-7_1984                           Q3_7_1984                 
Q3-8_1984                           Q3_8_1984                 
Q3-8A_1984                          Q3_8A_1984                
Q3-8C_M_1984                        Q3_8C_M_1984              
Q3-8C_Y_1984                        Q3_8C_Y_1984              
Q3-10A_1984                         Q3_10A_1984               
DEGREE-1A_1_1984                    DEGREE_1A_1_1984          
SCHOOL-33_1984                      SCHOOL_33_1984            
DEGREE-1A_2_1984                    DEGREE_1A_2_1984          
DEGREE-2_1984                       DEGREE_2_1984             
MIL-56_1984                         MIL_56_1984               
MIL-57_1984                         MIL_57_1984               
MIL-56A_1984                        MIL_56A_1984              
MIL-57A_1984                        MIL_57A_1984              
MIL-62_1984                         MIL_62_1984               
HGCREV84_1984                       HGCREV84_1984             
Q3-1_1985                           Q3_1_1985                 
Q3-4_1985                           Q3_4_1985                 
Q3-7_1985                           Q3_7_1985                 
Q3-8_1985                           Q3_8_1985                 
Q3-8A_1985                          Q3_8A_1985                
Q3-8C_M_1985                        Q3_8C_M_1985              
Q3-8C_Y_1985                        Q3_8C_Y_1985              
MIL-56_1985                         MIL_56_1985               
MIL-56A_1985                        MIL_56A_1985              
MIL-57A_1985                        MIL_57A_1985              
MIL-62_1985                         MIL_62_1985               
HGCREV85_1985                       HGCREV85_1985             
Q3-1_1986                           Q3_1_1986                 
Q3-4_1986                           Q3_4_1986                 
Q3-7_1986                           Q3_7_1986                 
Q3-8_1986                           Q3_8_1986                 
Q3-8A_1986                          Q3_8A_1986                
Q3-8C~M_1986                        Q3_8C_M_1986              
Q3-8C~Y_1986                        Q3_8C_Y_1986              
HGCREV86_1986                       HGCREV86_1986             
Q3-1_1987                           Q3_1_1987                 
Q3-4_1987                           Q3_4_1987                 
Q3-7_1987                           Q3_7_1987                 
Q3-8_1987                           Q3_8_1987                 
Q3-8A_1987                          Q3_8A_1987                
Q3-8C_M_1987                        Q3_8C_M_1987              
Q3-8C_Y_1987                        Q3_8C_Y_1987              
HGCREV87_1987                       HGCREV87_1987             
Q3-1_1988                           Q3_1_1988                 
Q3-4_1988                           Q3_4_1988                 
Q3-7_1988                           Q3_7_1988                 
Q3-8_1988                           Q3_8_1988                 
Q3-8A_1988                          Q3_8A_1988                
Q3-8C_M_1988                        Q3_8C_M_1988              
Q3-8C_Y_1988                        Q3_8C_Y_1988              
Q3-10B_1988                         Q3_10B_1988               
Q3-10C_M_1988                       Q3_10C_M_1988             
Q3-10C_Y_1988                       Q3_10C_Y_1988             
HGCREV88_1988                       HGCREV88_1988             
Q3-1_1989                           Q3_1_1989                 
Q3-4_1989                           Q3_4_1989                 
Q3-7_1989                           Q3_7_1989                 
Q3-8_1989                           Q3_8_1989                 
Q3-8A_1989                          Q3_8A_1989                
Q3-8C_M_1989                        Q3_8C_M_1989              
Q3-8C_Y_1989                        Q3_8C_Y_1989              
Q3-10A_1989                         Q3_10A_1989               
Q3-10B_1989                         Q3_10B_1989               
Q3-10C_M_1989                       Q3_10C_M_1989             
Q3-10C_Y_1989                       Q3_10C_Y_1989             
HGCREV89_1989                       HGCREV89_1989             
Q3-1_1990                           Q3_1_1990                 
Q3-4_1990                           Q3_4_1990                 
Q3-7_1990                           Q3_7_1990                 
Q3-8_1990                           Q3_8_1990                 
Q3-8A_1990                          Q3_8A_1990                
Q3-8C_M_1990                        Q3_8C_M_1990              
Q3-8C_Y_1990                        Q3_8C_Y_1990              
Q3-10A_1990                         Q3_10A_1990               
Q3-10B_1990                         Q3_10B_1990               
Q3-10C_M_1990                       Q3_10C_M_1990             
Q3-10C_Y_1990                       Q3_10C_Y_1990             
HGCREV90_1990                       HGCREV90_1990             
Q3-1_1991                           Q3_1_1991                 
Q3-4_1991                           Q3_4_1991                 
Q3-7_1991                           Q3_7_1991                 
Q3-8_1991                           Q3_8_1991                 
Q3-8A_1991                          Q3_8A_1991                
Q3-8C_M_1991                        Q3_8C_M_1991              
Q3-8C_Y_1991                        Q3_8C_Y_1991              
Q3-10A_1991                         Q3_10A_1991               
Q3-10B_1991                         Q3_10B_1991               
Q3-10C_M_1991                       Q3_10C_M_1991             
Q3-10C_Y_1991                       Q3_10C_Y_1991             
HGCREV91_1991                       HGCREV91_1991             
Q3-1_1992                           Q3_1_1992                 
Q3-4_1992                           Q3_4_1992                 
Q3-7_1992                           Q3_7_1992                 
Q3-8_1992                           Q3_8_1992                 
Q3-8A_1992                          Q3_8A_1992                
Q3-8C_M_1992                        Q3_8C_M_1992              
Q3-8C_Y_1992                        Q3_8C_Y_1992              
Q3-10A_1992                         Q3_10A_1992               
Q3-10B_1992                         Q3_10B_1992               
Q3-10C_M_1992                       Q3_10C_M_1992             
Q3-10C_Y_1992                       Q3_10C_Y_1992             
HGCREV92_1992                       HGCREV92_1992             
Q3-1_1993                           Q3_1_1993                 
Q3-4_1993                           Q3_4_1993                 
Q3-7_1993                           Q3_7_1993                 
Q3-8_1993                           Q3_8_1993                 
Q3-8A_1993                          Q3_8A_1993                
Q3-8B~M_1993                        Q3_8B_M_1993              
Q3-8B~Y_1993                        Q3_8B_Y_1993              
Q3-10A_1993                         Q3_10A_1993               
Q3-10B_1993                         Q3_10B_1993               
Q3-10C~M_1993                       Q3_10C_M_1993             
Q3-10C~Y_1993                       Q3_10C_Y_1993             
HGCREV93_1993                       HGCREV93_1993             
Q3-1_1994                           Q3_1_1994                 
Q3-4_1994                           Q3_4_1994                 
Q3-7_1994                           Q3_7_1994                 
Q3-8_1994                           Q3_8_1994                 
Q3-8A_1994                          Q3_8A_1994                
Q3-8B~M_1994                        Q3_8B_M_1994              
Q3-8B~Y_1994                        Q3_8B_Y_1994              
Q3-8C~M_1994                        Q3_8C_M_1994              
Q3-8C~Y_1994                        Q3_8C_Y_1994              
Q3-10A_1994                         Q3_10A_1994               
Q3-10B_1994                         Q3_10B_1994               
Q3-10C~M_1994                       Q3_10C_M_1994             
Q3-10C~Y_1994                       Q3_10C_Y_1994             
HGCREV94_1994                       HGCREV94_1994             
HGCREV96_1996                       HGCREV96_1996             
Q3-1_1996                           Q3_1_1996                 
Q3-4_1996                           Q3_4_1996                 
Q3-7_1996                           Q3_7_1996                 
Q3-8_1996                           Q3_8_1996                 
Q3-8A_1996                          Q3_8A_1996                
Q3-8B~M_1996                        Q3_8B_M_1996              
Q3-8B~Y_1996                        Q3_8B_Y_1996              
Q3-8C~M_1996                        Q3_8C_M_1996              
Q3-8C~Y_1996                        Q3_8C_Y_1996              
Q3-10A_1996                         Q3_10A_1996               
Q3-10B_1996                         Q3_10B_1996               
Q3-10C~M_1996                       Q3_10C_M_1996             
Q3-10C~Y_1996                       Q3_10C_Y_1996             
Q3-1_1998                           Q3_1_1998                 
Q3-4_1998                           Q3_4_1998                 
Q3-7_1998                           Q3_7_1998                 
Q3-8_1998                           Q3_8_1998                 
Q3-8A_1998                          Q3_8A_1998                
Q3-8B~M_1998                        Q3_8B_M_1998              
Q3-8B~Y_1998                        Q3_8B_Y_1998              
Q3-8C~M_1998                        Q3_8C_M_1998              
Q3-8C~Y_1998                        Q3_8C_Y_1998              
Q3-10A_1998                         Q3_10A_1998               
Q3-10B_1998                         Q3_10B_1998               
Q3-10C~M_1998                       Q3_10C_M_1998             
Q3-10C~Y_1998                       Q3_10C_Y_1998             
Q11-H40CHRC-13A_1998                Q11_H40CHRC_13A_1998      
Q11-H40CHRC-13B_1998                Q11_H40CHRC_13B_1998      
HGCREV98_1998                       HGCREV98_1998             
Q3-1_2000                           Q3_1_2000                 
Q3-4_2000                           Q3_4_2000                 
Q3-7_2000                           Q3_7_2000                 
Q3-8_2000                           Q3_8_2000                 
Q3-8A_2000                          Q3_8A_2000                
Q3-8B~M_2000                        Q3_8B_M_2000              
Q3-8B~Y_2000                        Q3_8B_Y_2000              
Q3-8C~M_2000                        Q3_8C_M_2000              
Q3-8C~Y_2000                        Q3_8C_Y_2000              
Q3-10A_2000                         Q3_10A_2000               
Q3-10B_2000                         Q3_10B_2000               
Q3-10C~M_2000                       Q3_10C_M_2000             
Q3-10C~Y_2000                       Q3_10C_Y_2000             
Q11-H40CHRC-13A_2000                Q11_H40CHRC_13A_2000      
Q11-H40CHRC-13B_2000                Q11_H40CHRC_13B_2000      
HGCREV00_2000                       HGCREV00_2000             
Q3-1_2002                           Q3_1_2002                 
Q3-4_2002                           Q3_4_2002                 
Q3-7_2002                           Q3_7_2002                 
Q3-8_2002                           Q3_8_2002                 
Q3-8A_2002                          Q3_8A_2002                
Q3-8B~M_2002                        Q3_8B_M_2002              
Q3-8B~Y_2002                        Q3_8B_Y_2002              
Q3-8C~M_2002                        Q3_8C_M_2002              
Q3-8C~Y_2002                        Q3_8C_Y_2002              
Q3-10A_2002                         Q3_10A_2002               
Q3-10B_2002                         Q3_10B_2002               
Q3-10C~M_2002                       Q3_10C_M_2002             
Q3-10C~Y_2002                       Q3_10C_Y_2002             
HGCREV02_2002                       HGCREV02_2002             
Q3-1_2004                           Q3_1_2004                 
Q3-4_2004                           Q3_4_2004                 
Q3-7_2004                           Q3_7_2004                 
Q3-8_2004                           Q3_8_2004                 
Q3-8A_2004                          Q3_8A_2004                
Q3-8B~M_2004                        Q3_8B_M_2004              
Q3-8B~Y_2004                        Q3_8B_Y_2004              
Q3-8C~M_2004                        Q3_8C_M_2004              
Q3-8C~Y_2004                        Q3_8C_Y_2004              
Q3-10A_2004                         Q3_10A_2004               
Q3-10B_2004                         Q3_10B_2004               
Q3-10C~M_2004                       Q3_10C_M_2004             
Q3-10C~Y_2004                       Q3_10C_Y_2004             
HGCREV04_2004                       HGCREV04_2004             
Q3-1_2006                           Q3_1_2006                 
Q3-4_2006                           Q3_4_2006                 
Q3-7_2006                           Q3_7_2006                 
Q3-8_2006                           Q3_8_2006                 
Q3-8A_2006                          Q3_8A_2006                
Q3-8B~M_2006                        Q3_8B_M_2006              
Q3-8B~Y_2006                        Q3_8B_Y_2006              
Q3-8C~M_2006                        Q3_8C_M_2006              
Q3-8C~Y_2006                        Q3_8C_Y_2006              
Q3-10A_2006                         Q3_10A_2006               
Q3-10B_2006                         Q3_10B_2006               
Q3-10C~M_2006                       Q3_10C_M_2006             
Q3-10C~Y_2006                       Q3_10C_Y_2006             
HGCREV06_2006                       HGCREV06_2006             
Q3-1_2008                           Q3_1_2008                 
Q3-4_2008                           Q3_4_2008                 
Q3-7_2008                           Q3_7_2008                 
Q3-8_2008                           Q3_8_2008                 
Q3-8A_2008                          Q3_8A_2008                
Q3-8B~M_2008                        Q3_8B_M_2008              
Q3-8B~Y_2008                        Q3_8B_Y_2008              
Q3-8C~M_2008                        Q3_8C_M_2008              
Q3-8C~Y_2008                        Q3_8C_Y_2008              
Q3-10A_2008                         Q3_10A_2008               
Q3-10B_2008                         Q3_10B_2008               
Q3-10C~M_2008                       Q3_10C_M_2008             
Q3-10C~Y_2008                       Q3_10C_Y_2008             
Q3-10D_2008                         Q3_10D_2008               
Q3-10E~M_2008                       Q3_10E_M_2008             
Q3-10E~Y_2008                       Q3_10E_Y_2008             
HGCREV08_2008                       HGCREV08_2008             
Q3-1_2010                           Q3_1_2010                 
Q3-4_2010                           Q3_4_2010                 
Q3-7_2010                           Q3_7_2010                 
Q3-8_2010                           Q3_8_2010                 
Q3-8A_2010                          Q3_8A_2010                
Q3-8B~M_2010                        Q3_8B_M_2010              
Q3-8B~Y_2010                        Q3_8B_Y_2010              
Q3-8C~M_2010                        Q3_8C_M_2010              
Q3-8C~Y_2010                        Q3_8C_Y_2010              
Q3-10A_2010                         Q3_10A_2010               
Q3-10B_2010                         Q3_10B_2010               
Q3-10C~M_2010                       Q3_10C_M_2010             
Q3-10C~Y_2010                       Q3_10C_Y_2010             
Q3-10D_2010                         Q3_10D_2010               
Q3-10E~M_2010                       Q3_10E_M_2010             
Q3-10E~Y_2010                       Q3_10E_Y_2010             
HGCREV10_2010                       HGCREV10_2010             
Q3-1_2012                           Q3_1_2012                 
Q3-4_2012                           Q3_4_2012                 
Q3-7_2012                           Q3_7_2012                 
Q3-8_2012                           Q3_8_2012                 
Q3-8A_2012                          Q3_8A_2012                
Q3-8B~M_2012                        Q3_8B_M_2012              
Q3-8B~Y_2012                        Q3_8B_Y_2012              
Q3-8C~M_2012                        Q3_8C_M_2012              
Q3-8C~Y_2012                        Q3_8C_Y_2012              
Q3-10A_2012                         Q3_10A_2012               
Q3-10B_2012                         Q3_10B_2012               
Q3-10C~M_2012                       Q3_10C_M_2012             
Q3-10C~Y_2012                       Q3_10C_Y_2012             
Q3-10D_2012                         Q3_10D_2012               
Q3-10E~M_2012                       Q3_10E_M_2012             
Q3-10E~Y_2012                       Q3_10E_Y_2012             
HGCREV12_2012                       HGCREV12_2012             
Q3-1_2014                           Q3_1_2014                 
Q3-4_2014                           Q3_4_2014                 
Q3-7_2014                           Q3_7_2014                 
Q3-8_2014                           Q3_8_2014                 
Q3-8A_2014                          Q3_8A_2014                
Q3-8B~M_2014                        Q3_8B_M_2014              
Q3-8B~Y_2014                        Q3_8B_Y_2014              
Q3-8C~M_2014                        Q3_8C_M_2014              
Q3-8C~Y_2014                        Q3_8C_Y_2014              
Q3-10A_2014                         Q3_10A_2014               
Q3-10B_2014                         Q3_10B_2014               
Q3-10C~M_2014                       Q3_10C_M_2014             
Q3-10C~Y_2014                       Q3_10C_Y_2014             
Q3-10C_CHK0_2014                    Q3_10C_CHK0_2014          
Q3-10D_2014                         Q3_10D_2014               
Q3-10E~M_2014                       Q3_10E_M_2014             
Q3-10E~Y_2014                       Q3_10E_Y_2014             
HGCREV14_2014                       HGCREV14_2014             
Q3-1_2016                           Q3_1_2016                 
Q3-4_2016                           Q3_4_2016                 
Q3-7_2016                           Q3_7_2016                 
Q3-8_2016                           Q3_8_2016                 
Q3-8A_2016                          Q3_8A_2016                
Q3-8B~M_2016                        Q3_8B_M_2016              
Q3-8B~Y_2016                        Q3_8B_Y_2016              
Q3-8C~M_2016                        Q3_8C_M_2016              
Q3-8C~Y_2016                        Q3_8C_Y_2016              
Q3-10A_2016                         Q3_10A_2016               
Q3-10B_2016                         Q3_10B_2016               
Q3-10C~M_2016                       Q3_10C_M_2016             
Q3-10C~Y_2016                       Q3_10C_Y_2016             
Q3-10C_CHK0_2016                    Q3_10C_CHK0_2016          
Q3-10D_2016                         Q3_10D_2016               
Q3-10E~M_2016                       Q3_10E_M_2016             
Q3-10E~Y_2016                       Q3_10E_Y_2016             
HGCREV16_2016                       HGCREV16_2016             
CURDATE~D_2018                      CURDATE_D_2018            
CURDATE~M_2018                      CURDATE_M_2018            
CURDATE~Y_2018                      CURDATE_Y_2018            
Q3-1_2018                           Q3_1_2018                 
Q3-4_2018                           Q3_4_2018                 
Q3-7_2018                           Q3_7_2018                 
Q3-8_2018                           Q3_8_2018                 
Q3-8A_2018                          Q3_8A_2018                
Q3-8B~M_2018                        Q3_8B_M_2018              
Q3-8B~Y_2018                        Q3_8B_Y_2018              
Q3-8C~M_2018                        Q3_8C_M_2018              
Q3-8C~Y_2018                        Q3_8C_Y_2018              
Q3-10A_2018                         Q3_10A_2018               
Q3-10B_2018                         Q3_10B_2018               
Q3-10C~M_2018                       Q3_10C_M_2018             
Q3-10C~Y_2018                       Q3_10C_Y_2018             
Q3-10C_CHK0_2018                    Q3_10C_CHK0_2018          
Q3-10D_2018                         Q3_10D_2018               
Q3-10E~M_2018                       Q3_10E_M_2018             
Q3-10E~Y_2018                       Q3_10E_Y_2018             
Q3-20B.01_2018                      Q3_20B_01_2018            
Q3-20B.02_2018                      Q3_20B_02_2018            
Q3-20B.03_2018                      Q3_20B_03_2018            
Q3-28.01_2018                       Q3_28_01_2018             
Q3-28.02_2018                       Q3_28_02_2018             
Q3-28.03_2018                       Q3_28_03_2018             
Q3-29.01~M_2018                     Q3_29_01_M_2018           
Q3-29.01~Y_2018                     Q3_29_01_Y_2018           
Q3-29.02~M_2018                     Q3_29_02_M_2018           
Q3-29.02~Y_2018                     Q3_29_02_Y_2018           
Q3-29.03~M_2018                     Q3_29_03_M_2018           
Q3-29.03~Y_2018                     Q3_29_03_Y_2018           
Q3-1_2020                           Q3_1_2020                 
Q3-4_2020                           Q3_4_2020                 
Q3-7_2020                           Q3_7_2020                 
Q3-10A_2020                         Q3_10A_2020               
Q3-10B_2020                         Q3_10B_2020               
Q3-10C~M_2020                       Q3_10C_M_2020             
Q3-10C~Y_2020                       Q3_10C_Y_2020             
Q3-10D_2020                         Q3_10D_2020               
Q3-10E~M_2020                       Q3_10E_M_2020             
Q3-10E~Y_2020                       Q3_10E_Y_2020             
HGC_EVER_XRND                       HGC_EVER_XRND             
HGC_EVER_YEAR_XRND                  HGC_EVER_YEAR_XRND        
/*************************************/
/*     highest degree 1979           */
/*************************************/
hidegree_1979 = -4;
hidegree_m_1979 = -4;
hidegree_y_1979 = -4;
hdged_m_1979 = -4;
hdged_y_1979 = -4;
degreenum_1979 = 0;
degreehi4_1979 = -4;
degreehi4_m_1979 = -4;
degreehi4_y_1979 = -4;
trn_8a_1_1979r = -4;
trn_8a_2_1979r = -4;
trn_8a_3_1979r = -4;
trn_8a_4_1979r = -4;
mil_57a_1979r = -4;
mil_57b_1979r = -4;
array trn_8a_79  (m)  trn_8a_1_1979 trn_8a_2_1979 trn_8a_3_1979 trn_8a_4_1979;
array trn_8a_79r (m)  trn_8a_1_1979r trn_8a_2_1979r trn_8a_3_1979r trn_8a_4_1979r;
do m = 1 to 4;
  if (trn_8a_79 =   1) then trn_8a_79r = 2;
  if (trn_8a_79 =   2) then trn_8a_79r = 3;
  if (trn_8a_79 =   3) then trn_8a_79r = 5;
  if (trn_8a_79 = 176) then trn_8a_79r = 7;
end; 
array mil_57_79  (m)  mil_57a_1979 mil_57b_1979;
array mil_57_79r (m)  mil_57a_1979r mil_57b_1979r;
do m = 1 to 2;
  if (mil_57_79 = 1) then mil_57_79r = mil_57_79;
  if (mil_57_79 = 2) then mil_57_79r = mil_57_79;
  if (mil_57_79 = 3) then mil_57_79r = mil_57_79;
  if (mil_57_79 = 4) then mil_57_79r = 5;
  if (mil_57_79 = 5) then mil_57_79r = 6;
  if (mil_57_79 = 6) then mil_57_79r = 7;
  if (mil_57_79 = 7) then mil_57_79r = 8;
end;
if (q3_8c_m_1979 > -4) then do;
  hdged_m_1979 = q3_8c_m_1979;
  hdged_y_1979 = q3_8c_y_1979;
  end;
if (trn_8a_1_1979r > 0) then degreenum_1979 = (degreenum_1979 + 1);
if (trn_8a_2_1979r > 0) then degreenum_1979 = (degreenum_1979 + 1);
if (trn_8a_3_1979r > 0) then degreenum_1979 = (degreenum_1979 + 1);
if (trn_8a_4_1979r > 0) then degreenum_1979 = (degreenum_1979 + 1);
if (degreenum_1979 = 1) then do;
   degreehi4_1979 = trn_8a_1_1979r;
   degreehi4_m_1979 = trn_8e_1_m_1979;
   degreehi4_y_1979 = trn_8e_1_y_1979;
 end;
   
if (degreenum_1979 = 2) then do;
   if (trn_8a_2_1979r > trn_8a_1_1979r) then do;
     degreehi4_1979 = trn_8a_2_1979r;
     degreehi4_m_1979 = trn_8e_2_m_1979;
     degreehi4_y_1979 = trn_8e_2_y_1979;
     end;
   else if (trn_8a_2_1979r < trn_8a_1_1979r) then do;
     degreehi4_1979 = trn_8a_1_1979r;
     degreehi4_m_1979 = trn_8e_1_m_1979;
     degreehi4_y_1979 = trn_8e_1_y_1979;
     end;
 end;
if (degreenum_1979 = 3) then do;
   if (trn_8a_3_1979r > trn_8a_1_1979r & trn_8a_3_1979r > trn_8a_2_1979r) then do;
     degreehi4_1979 = trn_8a_3_1979r;
     degreehi4_m_1979 = trn_8e_3_m_1979;
     degreehi4_y_1979 = trn_8e_3_y_1979;
     end;
   else if (trn_8a_2_1979r > trn_8a_1_1979r & trn_8a_2_1979r > trn_8a_3_1979r) then do;
     degreehi4_1979 = trn_8a_2_1979r;
     degreehi4_m_1979 = trn_8e_2_m_1979;
     degreehi4_y_1979 = trn_8e_2_y_1979;
     end;
   else if (trn_8a_1_1979r > trn_8a_2_1979r & trn_8a_1_1979r > trn_8a_3_1979r) then do;
     degreehi4_1979 = trn_8a_1_1979r;
     degreehi4_m_1979 = trn_8e_1_m_1979;
     degreehi4_y_1979 = trn_8e_1_y_1979;
     end;
 end;
if (degreenum_1979 = 4) then do;
   if (trn_8a_4_1979r > trn_8a_1_1979r & trn_8a_4_1979r > trn_8a_2_1979r & trn_8a_4_1979r > trn_8a_3_1979r) then do;
     degreehi4_1979 = trn_8a_4_1979r;
     degreehi4_m_1979 = trn_8e_4_m_1979;
     degreehi4_y_1979 = trn_8e_4_y_1979;
     end;
   else if (trn_8a_3_1979r > trn_8a_1_1979r & trn_8a_3_1979r > trn_8a_2_1979r & trn_8a_3_1979r > trn_8a_4_1979r) then do;
     degreehi4_1979 = trn_8a_3_1979r;
     degreehi4_m_1979 = trn_8e_3_m_1979;
     degreehi4_y_1979 = trn_8e_3_y_1979;
     end;
   else if (trn_8a_2_1979r > trn_8a_1_1979r & trn_8a_2_1979r > trn_8a_3_1979r & trn_8a_2_1979r > trn_8a_4_1979r) then do;
     degreehi4_1979 = trn_8a_2_1979r;
     degreehi4_m_1979 = trn_8e_2_m_1979;
     degreehi4_y_1979 = trn_8e_2_y_1979;
     end;
   else if (trn_8a_1_1979r > trn_8a_2_1979r & trn_8a_1_1979r > trn_8a_3_1979r & trn_8a_1_1979r > trn_8a_4_1979r) then do;
     degreehi4_1979 = trn_8a_1_1979r;
     degreehi4_m_1979 = trn_8e_1_m_1979;
     degreehi4_y_1979 = trn_8e_1_y_1979;
     end;
 end;
if (degreehi4_1979 > 0) then do;
  hidegree_1979 = degreehi4_1979;
  hidegree_m_1979 = degreehi4_m_1979;
  hidegree_y_1979 = degreehi4_y_1979;
  end;
else if (mil_56a_1979 = 1) then do;
  hidegree_1979 = mil_57a_1979r;
  hidegree_m_1979 = -3;
  hidegree_y_1979 = -3;
  end;
else if (mil_56b_1979 = 1) then do;
  hidegree_1979 = mil_57b_1979r;
  hidegree_m_1979 = -3;
  hidegree_y_1979 = -3;
  end;
else if (q3_8a_1979 > -4) then do;
  hidegree_1979 = 1;
  hidegree_m_1979 = hdged_m_1979;
  hidegree_y_1979 = hdged_y_1979;
  end;
if (hidegree_1979 = 1 & hidegree_m_1979 = -3 & hdged_m_1979 > -4 & (mil_57a_1979 = 1 | mil_57b_1979 = 1)) then do;
  hidegree_m_1979 = hdged_m_1979;
  hidegree_y_1979 = hdged_y_1979;
end;
/*************************************/
/*     highest degree 1980           */
/*************************************/
hidegree_1980 = -4;
hidegree_m_1980 = -4;
hidegree_y_1980 = -4;
hdged_m_1980 = -4;
hdged_y_1980 = -4;
mil_57_1980r = -4;
mil_57a_1980r = -4;
degree_1a_1_1980r = -4;
degree_1a_2_1980r = -4;
array mil_57_80  (m)  mil_57_1980 mil_57a_1980;
array mil_57_80r (m)  mil_57_1980r mil_57a_1980r;
do m = 1 to 2;
  if (mil_57_80 = 1) then mil_57_80r = mil_57_80;
  if (mil_57_80 = 2) then mil_57_80r = mil_57_80;
  if (mil_57_80 = 3) then mil_57_80r = mil_57_80;
  if (mil_57_80 = 4) then mil_57_80r = 5;
  if (mil_57_80 = 5) then mil_57_80r = 6;
  if (mil_57_80 = 6) then mil_57_80r = 7;
  if (mil_57_80 = 7) then mil_57_80r = 8;
end;
array degree_1a_80  (m)  degree_1a_1_1980 degree_1a_2_1980;
array degree_1a_80r (m)  degree_1a_1_1980r degree_1a_2_1980r;
do m = 1 to 2;
  if (degree_1a_80 = -3) then degree_1a_80r = -3;
  if (degree_1a_80 =  1) then degree_1a_80r =  2;
  if (degree_1a_80 =  2) then degree_1a_80r =  3;
  if (degree_1a_80 =  3) then degree_1a_80r =  5;
  if (degree_1a_80 =  4) then degree_1a_80r =  8;
end;
if (q3_8c_m_1980 > -4) then do;
  hdged_m_1980 = q3_8c_m_1980;
  hdged_y_1980 = q3_8c_y_1980;
  end;
if (degree_1a_1_1980r > -4 & degree_1a_1_1980r > 0) then do;
  hidegree_1980 = degree_1a_1_1980r;
  hidegree_m_1980 = degree_1e_1_m_1980;
  hidegree_y_1980 = degree_1e_1_y_1980;
  end;
else if (degree_1f_1_1980 = 1 & degree_1a_1_1980r = -3 & degree_1a_2_1980r = -3) then do;
  hidegree_1980 = -3;
  hidegree_m_1980 = -3;
  hidegree_y_1980 = -3;
  end;
else if (degree_1f_1_1980 = 1 & degree_1a_1_1980r = -3 & degree_1a_2_1980r > 0) then do;
  hidegree_1980 = degree_1a_2_1980r;
  hidegree_m_1980 = degree_1e_2_m_1980;
  hidegree_y_1980 = degree_1e_2_y_1980;
  end;
else if (degree_1f_1_1980 = 1 & degree_1a_1_1980r > 0 & degree_1a_2_1980r = -3) then do;
  hidegree_1980 = degree_1a_1_1980r;
  hidegree_m_1980 = degree_1e_1_m_1980;
  hidegree_y_1980 = degree_1e_1_y_1980;
  end;
else if (degree_1f_1_1980 = 1 & degree_1a_1_1980r > 0 & degree_1a_2_1980r > 0 & degree_1a_2_1980r > degree_1a_1_1980r) then do;
  hidegree_1980 = degree_1a_2_1980r;
  hidegree_m_1980 = degree_1e_2_m_1980;
  hidegree_y_1980 = degree_1e_2_y_1980;
  end;
else if (degree_1f_1_1980 = 1 & degree_1a_1_1980r > 0 & degree_1a_2_1980r > 0 & degree_1a_1_1980r > degree_1a_2_1980r) then do;
  hidegree_1980 = degree_1a_1_1980r;
  hidegree_m_1980 = degree_1e_1_m_1980;
  hidegree_y_1980 = degree_1e_1_y_1980;
  end;
else if (degree_1f_1_1980 = 1 & degree_1a_1_1980r > 0 & degree_1a_2_1980r > 0 & degree_1a_1_1980r = degree_1a_2_1980r) then do;
  hidegree_1980 = degree_1a_1_1980r;
  hidegree_m_1980 = degree_1e_1_m_1980;
  hidegree_y_1980 = degree_1e_1_y_1980;
  end;
else if (mil_56_1980 = 1) then do;
  hidegree_1980 = mil_57_1980r;
  hidegree_m_1980 = -3;
  hidegree_y_1980 = -3;
  end;
else if (mil_56a_1980 = 1) then do;
  hidegree_1980 = mil_57a_1980r;
  hidegree_m_1980 = -3;
  hidegree_y_1980 = -3;
  end;
else if (q3_8a_1980 > -4) then do;
  hidegree_1980 = 1;
  hidegree_m_1980 = hdged_m_1980;
  hidegree_y_1980 = hdged_y_1980;
  end;
/*************************************/
/*     highest degree 1981           */
/*************************************/
hidegree_1981 = -4;
hidegree_m_1981 = -4;
hidegree_y_1981 = -4;
hdged_m_1981 = -4;
hdged_y_1981 = -4;
mil_57_1981r = -4;
mil_57a_1981r = -4;
degree_1a_1_1981r = -4;
degree_1a_2_1981r = -4;
array mil_57_81  (m)  mil_57_1981 mil_57a_1981;
array mil_57_81r (m)  mil_57_1981r mil_57a_1981r;
do m = 1 to 2;
  if (mil_57_81 = 1) then mil_57_81r = mil_57_81;
  if (mil_57_81 = 2) then mil_57_81r = mil_57_81;
  if (mil_57_81 = 3) then mil_57_81r = mil_57_81;
  if (mil_57_81 = 4) then mil_57_81r = 5;
  if (mil_57_81 = 5) then mil_57_81r = 6;
  if (mil_57_81 = 6) then mil_57_81r = 7;
  if (mil_57_81 = 7) then mil_57_81r = 8;
end;
array degree_1a_81  (m)  degree_1a_1_1981 degree_1a_2_1981;
array degree_1a_81r (m)  degree_1a_1_1981r degree_1a_2_1981r;
do m = 1 to 2;
  if (degree_1a_81 = -3) then degree_1a_81r = -3;
  if (degree_1a_81 =  1) then degree_1a_81r =  2;
  if (degree_1a_81 =  2) then degree_1a_81r =  3;
  if (degree_1a_81 =  3) then degree_1a_81r =  5;
  if (degree_1a_81 =  4) then degree_1a_81r =  8;
end;
if (q3_8c_m_1981 > -4) then do;
  hdged_m_1981 = q3_8c_m_1981;
  hdged_y_1981 = q3_8c_y_1981;
  end;
if (degree_1a_1_1981r > -4 & school_33_1981 = 0) then do;
  hidegree_1981 = degree_1a_1_1981r;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (school_33_1981 = 1 & degree_1a_1_1981r = -3 & degree_1a_2_1981r = -3) then do;
  hidegree_1981 = -3;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (school_33_1981 = 1 & degree_1a_1_1981r = -3 & degree_1a_2_1981r > 0) then do;
  hidegree_1981 = degree_1a_2_1981r;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (school_33_1981 = 1 & degree_1a_1_1981r > 0 & degree_1a_2_1981r = -3) then do;
  hidegree_1981 = degree_1a_1_1981r;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (school_33_1981 = 1 & degree_1a_1_1981r > 0 & degree_1a_2_1981r > 0 & degree_1a_2_1981r > degree_1a_1_1981r) then do;
  hidegree_1981 = degree_1a_2_1981r;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (school_33_1981 = 1 & degree_1a_1_1981r > 0 & degree_1a_2_1981r > 0 & degree_1a_1_1981r > degree_1a_2_1981r) then do;
  hidegree_1981 = degree_1a_1_1981r;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (school_33_1981 = 1 & degree_1a_1_1981r > 0 & degree_1a_2_1981r > 0 & degree_1a_1_1981r = degree_1a_2_1981r) then do;
  hidegree_1981 = degree_1a_1_1981r;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (mil_56_1981 = 1) then do;
  hidegree_1981 = mil_57_1981r;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (mil_56a_1981 = 1) then do;
  hidegree_1981 = mil_57a_1981r;
  hidegree_m_1981 = -3;
  hidegree_y_1981 = -3;
  end;
else if (q3_8a_1981 > -4) then do;
  hidegree_1981 = 1;
  hidegree_m_1981 = hdged_m_1981;
  hidegree_y_1981 = hdged_y_1981;
  end;
/*************************************/
/*     highest degree 1982           */
/*************************************/
hidegree_1982 = -4;
hidegree_m_1982 = -4;
hidegree_y_1982 = -4;
hdged_m_1982 = -4;
hdged_y_1982 = -4;
mil_57_1982r = -4;
mil_57a_1982r = -4;
degree_1a_1_1982r = -4;
degree_1a_2_1982r = -4;
array mil_57_82  (m)  mil_57_1982 mil_57a_1982;
array mil_57_82r (m)  mil_57_1982r mil_57a_1982r;
do m = 1 to 2;
  if (mil_57_82 = 1) then mil_57_82r = mil_57_82;
  if (mil_57_82 = 2) then mil_57_82r = mil_57_82;
  if (mil_57_82 = 3) then mil_57_82r = mil_57_82;
  if (mil_57_82 = 4) then mil_57_82r = 5;
  if (mil_57_82 = 5) then mil_57_82r = 6;
  if (mil_57_82 = 6) then mil_57_82r = 7;
  if (mil_57_82 = 7) then mil_57_82r = 8;
end;
array degree_1a_82  (m)  degree_1a_1_1982 degree_1a_2_1982;
array degree_1a_82r (m)  degree_1a_1_1982r degree_1a_2_1982r;
do m = 1 to 2;
  if (degree_1a_82 = -3) then degree_1a_82r = -3;
  if (degree_1a_82 =  1) then degree_1a_82r =  2;
  if (degree_1a_82 =  2) then degree_1a_82r =  3;
  if (degree_1a_82 =  3) then degree_1a_82r =  5;
  if (degree_1a_82 =  4) then degree_1a_82r =  8;
end;
if (q3_8c_m_1982 > -4) then do;
  hdged_m_1982 = q3_8c_m_1982;
  hdged_y_1982 = q3_8c_y_1982;
  end;
if (degree_1a_1_1982r > -4 & school_33_1982 = 0) then do;
  hidegree_1982 = degree_1a_1_1982r;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (school_33_1982 = 1 & degree_1a_1_1982r = -3 & degree_1a_2_1982r = -3) then do;
  hidegree_1982 = -3;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (school_33_1982 = 1 & degree_1a_1_1982r = -3 & degree_1a_2_1982r > 0) then do;
  hidegree_1982 = degree_1a_2_1982r;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (school_33_1982 = 1 & degree_1a_1_1982r > 0 & degree_1a_2_1982r = -3) then do;
  hidegree_1982 = degree_1a_1_1982r;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (school_33_1982 = 1 & degree_1a_1_1982r > 0 & degree_1a_2_1982r > 0 & degree_1a_2_1982r > degree_1a_1_1982r) then do;
  hidegree_1982 = degree_1a_2_1982r;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (school_33_1982 = 1 & degree_1a_1_1982r > 0 & degree_1a_2_1982r > 0 & degree_1a_1_1982r > degree_1a_2_1982r) then do;
  hidegree_1982 = degree_1a_1_1982r;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (school_33_1982 = 1 & degree_1a_1_1982r > 0 & degree_1a_2_1982r > 0 & degree_1a_1_1982r = degree_1a_2_1982r) then do;
  hidegree_1982 = degree_1a_1_1982r;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (mil_56_1982 = 1) then do;
  hidegree_1982 = mil_57_1982r;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (mil_56a_1982 = 1) then do;
  hidegree_1982 = mil_57a_1982r;
  hidegree_m_1982 = -3;
  hidegree_y_1982 = -3;
  end;
else if (q3_8a_1982 > -4) then do;
  hidegree_1982 = 1;
hidegree_m_1982 = hdged_m_1982;
  hidegree_y_1982 = hdged_y_1982;
  end;
/*************************************/
/*     highest degree 1983           */
/*************************************/
hidegree_1983 = -4;
hidegree_m_1983 = -4;
hidegree_y_1983 = -4;
hdged_m_1983 = -4;
hdged_y_1983 = -4;
mil_57_1983r = -4;
mil_57a_1983r = -4;
degree_1a_1_1983r = -4;
degree_1a_2_1983r = -4;
array mil_57_83  (m)  mil_57_1983 mil_57a_1983;
array mil_57_83r (m)  mil_57_1983r mil_57a_1983r;
do m = 1 to 2;
  if (mil_57_83 = 1) then mil_57_83r = mil_57_83;
  if (mil_57_83 = 2) then mil_57_83r = mil_57_83;
  if (mil_57_83 = 3) then mil_57_83r = mil_57_83;
  if (mil_57_83 = 4) then mil_57_83r = 5;
  if (mil_57_83 = 5) then mil_57_83r = 6;
  if (mil_57_83 = 6) then mil_57_83r = 7;
  if (mil_57_83 = 7) then mil_57_83r = 8;
end;
array degree_1a_83  (m)  degree_1a_1_1983 degree_1a_2_1983;
array degree_1a_83r (m)  degree_1a_1_1983r degree_1a_2_1983r;
do m = 1 to 2;
  if (degree_1a_83 = -3) then degree_1a_83r = -3;
  if (degree_1a_83 =  1) then degree_1a_83r =  2;
  if (degree_1a_83 =  2) then degree_1a_83r =  3;
  if (degree_1a_83 =  3) then degree_1a_83r =  5;
  if (degree_1a_83 =  4) then degree_1a_83r =  8;
end;
if (q3_8c_m_1983 > -4) then do;
  hdged_m_1983 = q3_8c_m_1983;
  hdged_y_1983 = q3_8c_y_1983;
  end;
if (degree_1a_1_1983r > -4 & school_33_1983 = 0) then do;
  hidegree_1983 = degree_1a_1_1983r;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (school_33_1983 = 1 & degree_1a_1_1983r = -3 & degree_1a_2_1983r = -3) then do;
  hidegree_1983 = -3;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (school_33_1983 = 1 & degree_1a_1_1983r = -3 & degree_1a_2_1983r > 0) then do;
  hidegree_1983 = degree_1a_2_1983r;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (school_33_1983 = 1 & degree_1a_1_1983r > 0 & degree_1a_2_1983r = -3) then do;
  hidegree_1983 = degree_1a_1_1983r;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (school_33_1983 = 1 & degree_1a_1_1983r > 0 & degree_1a_2_1983r > 0 & degree_1a_2_1983r > degree_1a_1_1983r) then do;
  hidegree_1983 = degree_1a_2_1983r;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (school_33_1983 = 1 & degree_1a_1_1983r > 0 & degree_1a_2_1983r > 0 & degree_1a_1_1983r > degree_1a_2_1983r) then do;
  hidegree_1983 = degree_1a_1_1983r;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (school_33_1983 = 1 & degree_1a_1_1983r > 0 & degree_1a_2_1983r > 0 & degree_1a_1_1983r = degree_1a_2_1983r) then do;
  hidegree_1983 = degree_1a_1_1983r;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (mil_56_1983 = 1) then do;
  hidegree_1983 = mil_57_1983r;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (mil_56a_1983 = 1) then do;
  hidegree_1983 = mil_57a_1983r;
  hidegree_m_1983 = -3;
  hidegree_y_1983 = -3;
  end;
else if (q3_8a_1983 > -4) then do;
  hidegree_1983 = 1;
  hidegree_m_1983 = hdged_m_1983;
  hidegree_y_1983 = hdged_y_1983;
  end;
/*************************************/
/*     highest degree 1984           */
/*************************************/
hidegree_1984 = -4;
hidegree_m_1984 = -4;
hidegree_y_1984 = -4;
hdged_m_1984 = -4;
hdged_y_1984 = -4;
mil_57_1984r = -4;
mil_57a_1984r = -4;
degree_1a_1_1984r = -4;
degree_1a_2_1984r = -4;
array mil_57_84  (m)  mil_57_1984 mil_57a_1984;
array mil_57_84r (m)  mil_57_1984r mil_57a_1984r;
do m = 1 to 2;
  if (mil_57_84 = 1) then mil_57_84r = mil_57_84;
  if (mil_57_84 = 2) then mil_57_84r = mil_57_84;
  if (mil_57_84 = 3) then mil_57_84r = mil_57_84;
  if (mil_57_84 = 4) then mil_57_84r = 5;
  if (mil_57_84 = 5) then mil_57_84r = 6;
  if (mil_57_84 = 6) then mil_57_84r = 7;
  if (mil_57_84 = 7) then mil_57_84r = 8;
end;
array degree_1a_84  (m)  degree_1a_1_1984 degree_1a_2_1984;
array degree_1a_84r (m)  degree_1a_1_1984r degree_1a_2_1984r;
do m = 1 to 2;
  if (degree_1a_84 = -3) then degree_1a_84r = -3;
  if (degree_1a_84 =  1) then degree_1a_84r =  2;
  if (degree_1a_84 =  2) then degree_1a_84r =  3;
  if (degree_1a_84 =  3) then degree_1a_84r =  5;
  if (degree_1a_84 =  4) then degree_1a_84r =  8;
end;
if (q3_8c_m_1984 > -4) then do;
  hdged_m_1984 = q3_8c_m_1984;
  hdged_y_1984 = q3_8c_y_1984;
  end;
if (degree_1a_1_1984r > -4 & school_33_1984 = 0) then do;
  hidegree_1984 = degree_1a_1_1984r;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (school_33_1984 = 1 & degree_1a_1_1984r = -3 & degree_1a_2_1984r = -3) then do;
  hidegree_1984 = -3;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (school_33_1984 = 1 & degree_1a_1_1984r = -3 & degree_1a_2_1984r > 0) then do;
  hidegree_1984 = degree_1a_2_1984r;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (school_33_1984 = 1 & degree_1a_1_1984r > 0 & degree_1a_2_1984r = -3) then do;
  hidegree_1984 = degree_1a_1_1984r;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (school_33_1984 = 1 & degree_1a_1_1984r > 0 & degree_1a_2_1984r > 0 & degree_1a_2_1984r > degree_1a_1_1984r) then do;
  hidegree_1984 = degree_1a_2_1984r;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (school_33_1984 = 1 & degree_1a_1_1984r > 0 & degree_1a_2_1984r > 0 & degree_1a_1_1984r > degree_1a_2_1984r) then do;
  hidegree_1984 = degree_1a_1_1984r;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (school_33_1984 = 1 & degree_1a_1_1984r > 0 & degree_1a_2_1984r > 0 & degree_1a_1_1984r = degree_1a_2_1984r) then do;
  hidegree_1984 = degree_1a_1_1984r;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (mil_56_1984 = 1) then do;
  hidegree_1984 = mil_57_1984r;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (mil_56a_1984 = 1) then do;
  hidegree_1984 = mil_57a_1984r;
  hidegree_m_1984 = -3;
  hidegree_y_1984 = -3;
  end;
else if (q3_8a_1984 > -4) then do;
  hidegree_1984 = 1;
  hidegree_m_1984 = hdged_m_1984;
  hidegree_y_1984 = hdged_y_1984;
  end;
/*************************************/
/*     highest degree 1985           */
/*************************************/
hidegree_1985 = -4;
hidegree_m_1985 = -4;
hidegree_y_1985 = -4;
hdged_m_1985 = -4;
hdged_y_1985 = -4;
mil_57a_1985r = -4;
  if (mil_57a_1985 = 1) then mil_57a_1985r = mil_57a_1985;
  if (mil_57a_1985 = 2) then mil_57a_1985r = mil_57a_1985;
  if (mil_57a_1985 = 3) then mil_57a_1985r = mil_57a_1985;
  if (mil_57a_1985 = 4) then mil_57a_1985r = 5;
  if (mil_57a_1985 = 5) then mil_57a_1985r = 6;
  if (mil_57a_1985 = 6) then mil_57a_1985r = 7;
  if (mil_57a_1985 = 7) then mil_57a_1985r = 8;
if (q3_8c_m_1985 > -4) then do;
  hdged_m_1985 = q3_8c_m_1985;
  hdged_y_1985 = q3_8c_y_1985;
  end;
if (mil_56_1985 = 1 | mil_56a_1985 = 1) then do;
  hidegree_1985 = mil_57a_1985r;
  hidegree_m_1985 = -3;
  hidegree_y_1985 = -3;
  end;
else if (q3_8a_1985 > -4) then do;
  hidegree_1985 = 1;
  hidegree_m_1985 = hdged_m_1985;
  hidegree_y_1985 = hdged_y_1985;
  end;
/*************************************/
/*     highest degree 1986           */
/*************************************/
hidegree_1986 = -4;
hidegree_m_1986 = -4;
hidegree_y_1986 = -4;
hdged_m_1986 = -4;
hdged_y_1986 = -4;
if (q3_8c_m_1986 > -4) then do;
  hdged_m_1986 = q3_8c_m_1986;
  hdged_y_1986 = q3_8c_y_1986;
  end;
if (q3_8a_1986 > -4) then do;
  hidegree_1986 = 1;
  hidegree_m_1986 = hdged_m_1986;
  hidegree_y_1986 = hdged_y_1986;
  end;
/*************************************/
/*     highest degree 1987           */
/*************************************/
hidegree_1987 = -4;
hidegree_m_1987 = -4;
hidegree_y_1987 = -4;
hdged_m_1987 = -4;
hdged_y_1987 = -4;
if (q3_8c_m_1987 > -4) then do;
  hdged_m_1987 = q3_8c_m_1987;
  hdged_y_1987 = q3_8c_y_1987;
  end;
if (q3_8a_1987 > -4) then do;
  hidegree_1987 = 1;
  hidegree_m_1987 = hdged_m_1987;
  hidegree_y_1987 = hdged_y_1987;
  end;
/*************************************/
/*     highest degree 1988           */
/*************************************/
hidegree_1988 = -4;
hidegree_m_1988 = -4;
hidegree_y_1988 = -4;
hdged_m_1988 = -4;
hdged_y_1988 = -4;
if (q3_8c_m_1988 > -4) then do;
  hdged_m_1988 = q3_8c_m_1988;
  hdged_y_1988 = q3_8c_y_1988;
  end;
if (q3_10b_1988 > -4) then do;
  hidegree_1988 = q3_10b_1988;
  hidegree_m_1988 = q3_10c_m_1988;
  hidegree_y_1988 = q3_10c_y_1988;
  end;
else if (q3_8a_1988 > -4) then do;
  hidegree_1988 = 1;
  hidegree_m_1988 = hdged_m_1988;
  hidegree_y_1988 = hdged_y_1988;
  end;
/*************************************/
/*     highest degree 1989           */
/*************************************/
hidegree_1989 = -4;
hidegree_m_1989 = -4;
hidegree_y_1989 = -4;
hdged_m_1989 = -4;
hdged_y_1989 = -4;
if (q3_8c_m_1989 > -4) then do;
  hdged_m_1989 = q3_8c_m_1989;
  hdged_y_1989 = q3_8c_y_1989;
  end;
if (q3_10b_1989 > -4) then do;
  hidegree_1989 = q3_10b_1989;
  hidegree_m_1989 = q3_10c_m_1989;
  hidegree_y_1989 = q3_10c_y_1989;
  end;
else if (q3_8a_1989 > -4) then do;
  hidegree_1989 = 1;
  hidegree_m_1989 = hdged_m_1989;
  hidegree_y_1989 = hdged_y_1989;
  end;
/*************************************/
/*     highest degree 1990           */
/*************************************/
hidegree_1990 = -4;
hidegree_m_1990 = -4;
hidegree_y_1990 = -4;
hdged_m_1990 = -4;
hdged_y_1990 = -4;
if (q3_8c_m_1990 > -4) then do;
  hdged_m_1990 = q3_8c_m_1990;
  hdged_y_1990 = q3_8c_y_1990;
  end;
if (q3_10b_1990 > -4) then do;
  hidegree_1990 = q3_10b_1990;
  hidegree_m_1990 = q3_10c_m_1990;
  hidegree_y_1990 = q3_10c_y_1990;
  end;
else if (q3_8a_1990 > -4) then do;
  hidegree_1990 = 1;
  hidegree_m_1990 = hdged_m_1990;
  hidegree_y_1990 = hdged_y_1990;
  end;
/*************************************/
/*     highest degree 1991           */
/*************************************/
hidegree_1991 = -4;
hidegree_m_1991 = -4;
hidegree_y_1991 = -4;
hdged_m_1991 = -4;
hdged_y_1991 = -4;
if (q3_8c_m_1991 > -4) then do;
  hdged_m_1991 = q3_8c_m_1991;
  hdged_y_1991 = q3_8c_y_1991;
  end;
if (q3_10b_1991 > -4) then do;
  hidegree_1991 = q3_10b_1991;
  hidegree_m_1991 = q3_10c_m_1991;
  hidegree_y_1991 = q3_10c_y_1991;
  end;
else if (q3_8a_1991 > -4) then do;
  hidegree_1991 = 1;
  hidegree_m_1991 = hdged_m_1991;
  hidegree_y_1991 = hdged_y_1991;
  end;
/*************************************/
/*     highest degree 1992           */
/*************************************/
hidegree_1992 = -4;
hidegree_m_1992 = -4;
hidegree_y_1992 = -4;
hdged_m_1992 = -4;
hdged_y_1992 = -4;
if (q3_8c_m_1992 > -4) then do;
  hdged_m_1992 = q3_8c_m_1992;
  hdged_y_1992 = q3_8c_y_1992;
  end;
if (q3_10b_1992 > -4) then do;
  hidegree_1992 = q3_10b_1992;
  hidegree_m_1992 = q3_10c_m_1992;
  hidegree_y_1992 = q3_10c_y_1992;
  end;
else if (q3_8a_1992 > -4) then do;
  hidegree_1992 = 1;
  hidegree_m_1992 = hdged_m_1992;
  hidegree_y_1992 = hdged_y_1992;
  end;
/*************************************/
/*     highest degree 1993           */
/*************************************/
hidegree_1993 = -4;
hidegree_m_1993 = -4;
hidegree_y_1993 = -4;
hdged_m_1993 = -4;
hdged_y_1993 = -4;
if (q3_8b_m_1993 > -4) then do;
  hdged_m_1993 = q3_8b_m_1993;
  hdged_y_1993 = q3_8b_y_1993;
  end;
if (q3_10b_1993 > -4) then do;
  hidegree_1993 = q3_10b_1993;
  hidegree_m_1993 = q3_10c_m_1993;
  hidegree_y_1993 = q3_10c_y_1993;
  end;
else if (q3_8a_1993 > -4) then do;
  hidegree_1993 = 1;
  hidegree_m_1993 = hdged_m_1993;
  hidegree_y_1993 = hdged_y_1993;
  end;
/*************************************/
/*     highest degree 1994           */
/*************************************/
hidegree_1994 = -4;
hidegree_m_1994 = -4;
hidegree_y_1994 = -4;
hdged_m_1994 = -4;
hdged_y_1994 = -4;
if (q3_8b_m_1994 > -4) then do;
  hdged_m_1994 = q3_8b_m_1994;
  hdged_y_1994 = q3_8b_y_1994;
  end;
else if (q3_8c_m_1994 > -4) then do;
  hdged_m_1994 = q3_8c_m_1994;
  hdged_y_1994 = q3_8c_y_1994;
  end;
if (q3_10b_1994 > -4) then do;
  hidegree_1994 = q3_10b_1994;
  hidegree_m_1994 = q3_10c_m_1994;
  hidegree_y_1994 = q3_10c_y_1994;
  end;
else if (q3_8a_1994 > -4) then do;
  hidegree_1994 = 1;
  hidegree_m_1994 = hdged_m_1994;
  hidegree_y_1994 = hdged_y_1994;
  end;
/*************************************/
/*     highest degree 1996           */
/*************************************/
hidegree_1996 = -4;
hidegree_m_1996 = -4;
hidegree_y_1996 = -4;
hdged_m_1996 = -4;
hdged_y_1996 = -4;
if (q3_8b_m_1996 > -4) then do;
  hdged_m_1996 = q3_8b_m_1996;
  hdged_y_1996 = q3_8b_y_1996;
  end;
else if (q3_8c_m_1996 > -4) then do;
  hdged_m_1996 = q3_8c_m_1996;
  hdged_y_1996 = q3_8c_y_1996;
  end;
if (q3_10b_1996 > -4) then do;
  hidegree_1996 = q3_10b_1996;
  hidegree_m_1996 = q3_10c_m_1996;
  hidegree_y_1996 = q3_10c_y_1996;
  end;
else if (q3_8a_1996 > -4) then do;
  hidegree_1996 = 1;
  hidegree_m_1996 = hdged_m_1996;
  hidegree_y_1996 = hdged_y_1996;
  end;
/*************************************/
/*     highest degree 1998           */
/*************************************/
hidegree_1998 = -4;
hidegree_m_1998 = -4;
hidegree_y_1998 = -4;
hdged_m_1998 = -4;
hdged_y_1998 = -4;
if (q3_8b_m_1998 > -4) then do;
  hdged_m_1998 = q3_8b_m_1998;
  hdged_y_1998 = q3_8b_y_1998;
  end;
else if (q3_8c_m_1998 > -4) then do;
  hdged_m_1998 = q3_8c_m_1998;
  hdged_y_1998 = q3_8c_y_1998;
  end;
if (q3_10b_1998 > -4) then do;
  hidegree_1998 = q3_10b_1998;
  hidegree_m_1998 = q3_10c_m_1998;
  hidegree_y_1998 = q3_10c_y_1998;
  end;
else if (q3_8a_1998 > -4) then do;
  hidegree_1998 = 1;
  hidegree_m_1998 = hdged_m_1998;
  hidegree_y_1998 = hdged_y_1998;
  end;
/*************************************/
/*     highest degree 2000           */
/*************************************/
hidegree_2000 = -4;
hidegree_m_2000 = -4;
hidegree_y_2000 = -4;
hdged_m_2000 = -4;
hdged_y_2000 = -4;
if (q3_8b_m_2000 > -4) then do;
  hdged_m_2000 = q3_8b_m_2000;
  hdged_y_2000 = q3_8b_y_2000;
  end;
else if (q3_8c_m_2000 > -4) then do;
  hdged_m_2000 = q3_8c_m_2000;
  hdged_y_2000 = q3_8c_y_2000;
  end;
if (q3_10b_2000 > -4) then do;
  hidegree_2000 = q3_10b_2000;
  hidegree_m_2000 = q3_10c_m_2000;
  hidegree_y_2000 = q3_10c_y_2000;
  end;
else if (q3_8a_2000 > -4) then do;
  hidegree_2000 = 1;
  hidegree_m_2000 = hdged_m_2000;
  hidegree_y_2000 = hdged_y_2000;
  end;
/*************************************/
/*     highest degree 2002           */
/*************************************/
hidegree_2002 = -4;
hidegree_m_2002 = -4;
hidegree_y_2002 = -4;
hdged_m_2002 = -4;
hdged_y_2002 = -4;
if (q3_8b_m_2002 > -4) then do;
  hdged_m_2002 = q3_8b_m_2002;
  hdged_y_2002 = q3_8b_y_2002;
  end;
else if (q3_8c_m_2002 > -4) then do;
  hdged_m_2002 = q3_8c_m_2002;
  hdged_y_2002 = q3_8c_y_2002;
  end;
if (q3_10b_2002 > -4) then do;
  hidegree_2002 = q3_10b_2002;
  hidegree_m_2002 = q3_10c_m_2002;
  hidegree_y_2002 = q3_10c_y_2002;
  end;
else if (q3_8a_2002 > -4) then do;
  hidegree_2002 = 1;
  hidegree_m_2002 = hdged_m_2002;
  hidegree_y_2002 = hdged_y_2002;
  end;
/*************************************/
/*     highest degree 2004           */
/*************************************/
hidegree_2004 = -4;
hidegree_m_2004 = -4;
hidegree_y_2004 = -4;
hdged_m_2004 = -4;
hdged_y_2004 = -4;
if (q3_8b_m_2004 > -4) then do;
  hdged_m_2004 = q3_8b_m_2004;
  hdged_y_2004 = q3_8b_y_2004;
  end;
else if (q3_8c_m_2004 > -4) then do;
  hdged_m_2004 = q3_8c_m_2004;
  hdged_y_2004 = q3_8c_y_2004;
  end;
if (q3_10b_2004 > -4) then do;
  hidegree_2004 = q3_10b_2004;
  hidegree_m_2004 = q3_10c_m_2004;
  hidegree_y_2004 = q3_10c_y_2004;
  end;
else if (q3_8a_2004 > -4) then do;
  hidegree_2004 = 1;
  hidegree_m_2004 = hdged_m_2004;
  hidegree_y_2004 = hdged_y_2004;
  end;
/*************************************/
/*     highest degree 2006           */
/*************************************/
hidegree_2006 = -4;
hidegree_m_2006 = -4;
hidegree_y_2006 = -4;
hdged_m_2006 = -4;
hdged_y_2006 = -4;
if (q3_8b_m_2006 > -4) then do;
  hdged_m_2006 = q3_8b_m_2006;
  hdged_y_2006 = q3_8b_y_2006;
  end;
else if (q3_8c_m_2006 > -4) then do;
  hdged_m_2006 = q3_8c_m_2006;
  hdged_y_2006 = q3_8c_y_2006;
  end;
if (q3_10b_2006 > -4) then do;
  hidegree_2006 = q3_10b_2006;
  hidegree_m_2006 = q3_10c_m_2006;
  hidegree_y_2006 = q3_10c_y_2006;
  end;
else if (q3_8a_2006 > -4) then do;
  hidegree_2006 = 1;
  hidegree_m_2006 = hdged_m_2006;
  hidegree_y_2006 = hdged_y_2006;
  end;
/*************************************/
/*     highest degree 2008           */
/*************************************/
hidegree_2008 = -4;
hidegree_m_2008 = -4;
hidegree_y_2008 = -4;
hdged_m_2008 = -4;
hdged_y_2008 = -4;
if (q3_8b_m_2008 > -4) then do;
  hdged_m_2008 = q3_8b_m_2008;
  hdged_y_2008 = q3_8b_y_2008;
  end;
else if (q3_8c_m_2008 > -4) then do;
  hdged_m_2008 = q3_8c_m_2008;
  hdged_y_2008 = q3_8c_y_2008;
  end;
if (q3_10d_2008 > -4 & q3_10d_2008 ~= 0) then do;
  hidegree_2008 = q3_10d_2008;
  hidegree_m_2008 = q3_10e_m_2008;
  hidegree_y_2008 = q3_10e_y_2008;
  end;
else if (q3_10b_2008 > -4 & q3_10b_2008 ~= 0) then do;
  hidegree_2008 = q3_10b_2008;
  hidegree_m_2008 = q3_10c_m_2008;
  hidegree_y_2008 = q3_10c_y_2008;
  end;
else if (q3_8a_2008 > -4) then do;
  hidegree_2008 = 1;
  hidegree_m_2008 = hdged_m_2008;
  hidegree_y_2008 = hdged_y_2008;
  end;
/*************************************/
/*     highest degree 2010           */
/*************************************/
hidegree_2010 = -4;
hidegree_m_2010 = -4;
hidegree_y_2010 = -4;
hdged_m_2010 = -4;
hdged_y_2010 = -4;
if (q3_8b_m_2010 > -4) then do;
  hdged_m_2010 = q3_8b_m_2010;
  hdged_y_2010 = q3_8b_y_2010;
  end;
else if (q3_8c_m_2010 > -4) then do;
  hdged_m_2010 = q3_8c_m_2010;
  hdged_y_2010 = q3_8c_y_2010;
  end;
if (q3_10d_2010 > -4 & q3_10d_2010 ~= 0) then do;
  hidegree_2010 = q3_10d_2010;
  hidegree_m_2010 = q3_10e_m_2010;
  hidegree_y_2010 = q3_10e_y_2010;
  end;
else if (q3_10b_2010 > -4 & q3_10b_2010 ~= 0) then do;
  hidegree_2010 = q3_10b_2010;
  hidegree_m_2010 = q3_10c_m_2010;
  hidegree_y_2010 = q3_10c_y_2010;
  end;
else if (q3_8a_2010 > -4) then do;
  hidegree_2010 = 1;
  hidegree_m_2010 = hdged_m_2010;
  hidegree_y_2010 = hdged_y_2010;
  end;
/*************************************/
/*     highest degree 2012           */
/*************************************/
hidegree_2012 = -4;
hidegree_m_2012 = -4;
hidegree_y_2012 = -4;
hdged_m_2012 = -4;
hdged_y_2012 = -4;
if (q3_8b_m_2012 > -4) then do;
  hdged_m_2012 = q3_8b_m_2012;
  hdged_y_2012 = q3_8b_y_2012;
  end;
else if (q3_8c_m_2012 > -4) then do;
  hdged_m_2012 = q3_8c_m_2012;
  hdged_y_2012 = q3_8c_y_2012;
  end;
if (q3_10d_2012 > -4 & q3_10d_2012 ~= 0) then do;
  hidegree_2012 = q3_10d_2012;
  hidegree_m_2012 = q3_10e_m_2012;
  hidegree_y_2012 = q3_10e_y_2012;
  end;
else if (q3_10b_2012 > -4 & q3_10b_2012 ~= 0) then do;
  hidegree_2012 = q3_10b_2012;
  hidegree_m_2012 = q3_10c_m_2012;
  hidegree_y_2012 = q3_10c_y_2012;
  end;
else if (q3_8a_2012 > -4) then do;
  hidegree_2012 = 1;
  hidegree_m_2012 = hdged_m_2012;
  hidegree_y_2012 = hdged_y_2012;
  end;
/*************************************/
/*     highest degree 2014           */
/*************************************/
hidegree_2014 = -4;
hidegree_m_2014 = -4;
hidegree_y_2014 = -4;
hdged_m_2014 = -4;
hdged_y_2014 = -4;
if (q3_8b_m_2014 > -4) then do;
  hdged_m_2014 = q3_8b_m_2014;
  hdged_y_2014 = q3_8b_y_2014;
  end;
else if (q3_8c_m_2014 > -4) then do;
  hdged_m_2014 = q3_8c_m_2014;
  hdged_y_2014 = q3_8c_y_2014;
  end;
if (q3_10d_2014 > -4 & q3_10d_2014 ~= 0) then do;
  hidegree_2014 = q3_10d_2014;
  hidegree_m_2014 = q3_10e_m_2014;
  hidegree_y_2014 = q3_10e_y_2014;
  end;
else if (q3_10b_2014 > -4 & q3_10b_2014 ~= 0) then do;
  hidegree_2014 = q3_10b_2014;
  hidegree_m_2014 = q3_10c_m_2014;
  hidegree_y_2014 = q3_10c_y_2014;
  end;
else if (q3_8a_2014 > -4) then do;
  hidegree_2014 = 1;
  hidegree_m_2014 = hdged_m_2014;
  hidegree_y_2014 = hdged_y_2014;
  end;
/*************************************/
/*     highest degree 2016           */
/*************************************/
hidegree_2016 = -4;
hidegree_m_2016 = -4;
hidegree_y_2016 = -4;
hdged_m_2016 = -4;
hdged_y_2016 = -4;
if (q3_8b_m_2016 > -4) then do;
  hdged_m_2016 = q3_8b_m_2016;
  hdged_y_2016 = q3_8b_y_2016;
  end;
else if (q3_8c_m_2016 > -4) then do;
  hdged_m_2016 = q3_8c_m_2016;
  hdged_y_2016 = q3_8c_y_2016;
  end;
if (q3_10d_2016 > -4 & q3_10d_2016 ~= 0) then do;
  hidegree_2016 = q3_10d_2016;
  hidegree_m_2016 = q3_10e_m_2016;
  hidegree_y_2016 = q3_10e_y_2016;
  end;
else if (q3_10b_2016 > -4 & q3_10b_2016 ~= 0) then do;
  hidegree_2016 = q3_10b_2016;
  hidegree_m_2016 = q3_10c_m_2016;
  hidegree_y_2016 = q3_10c_y_2016;
  end;
else if (q3_8a_2016 > -4) then do;
  hidegree_2016 = 1;
  hidegree_m_2016 = hdged_m_2016;
  hidegree_y_2016 = hdged_y_2016;
  end;
if (hidegree_2016 = 9) then hidegree_2016 = 8;
/*************************************/
/*     highest degree 2018           */
/*************************************/
hidegree_2018 = -4;
hidegree_m_2018 = -4;
hidegree_y_2018 = -4;
hdged_m_2018 = -4;
hdged_y_2018 = -4;
q3_20b_01_2018r = -4;
q3_20b_02_2018r = -4;
q3_20b_03_2018r = -4;
array q3_20b_2018  (m) q3_20b_01_2018 q3_20b_02_2018 q3_20b_03_2018;
array q3_20b_2018r (m) q3_20b_01_2018r q3_20b_02_2018r q3_20b_03_2018r;
do m = 1 to 3;
  if (q3_20b_2018 =  1) then q3_20b_2018r = 2;
  if (q3_20b_2018 =  3) then q3_20b_2018r = 3;
  if (q3_20b_2018 =  4) then q3_20b_2018r = 5;
  if (q3_20b_2018 =  5) then q3_20b_2018r = 6;
  if (q3_20b_2018 =  6) then q3_20b_2018r = 7;
  if (q3_20b_2018 =  8) then q3_20b_2018r = 8;
  if (q3_20b_2018 =  9) then q3_20b_2018r = 1;
  if (q3_20b_2018 = 10) then q3_20b_2018r = 5;
end;
if (q3_8b_m_2018 > -4) then do;
  hdged_m_2018 = q3_8b_m_2018;
  hdged_y_2018 = q3_8b_y_2018;
  end;
else if (q3_8c_m_2018 > -4) then do;
  hdged_m_2018 = q3_8c_m_2018;
  hdged_y_2018 = q3_8c_y_2018;
  end;
if (q3_10d_2018 > -4 & q3_10d_2018 ~= 0) then do;
  hidegree_2018 = q3_10d_2018;
  hidegree_m_2018 = q3_10e_m_2018;
  hidegree_y_2018 = q3_10e_y_2018;
  end;
else if (q3_10b_2018 > -4 & q3_10b_2018 ~= 0) then do;
  hidegree_2018 = q3_10b_2018;
  hidegree_m_2018 = q3_10c_m_2018;
  hidegree_y_2018 = q3_10c_y_2018;
  end;
else if (q3_20b_01_2018r > -4 & q3_20b_02_2018r = -4 & q3_20b_03_2018r = -4) then do;
  hidegree_2018 = q3_20b_01_2018r;
  hidegree_m_2018 = q3_29_01_m_2018;
  hidegree_y_2018 = q3_29_01_y_2018;
  end;
else if (q3_8a_2018 > -4) then do;
  hidegree_2018 = 1;
  hidegree_m_2018 = hdged_m_2018;
  hidegree_y_2018 = hdged_y_2018;
  end;
 
/*************************************/
/*     highest degree 2020           */
/*************************************/
hidegree_2020 = -4;
hidegree_m_2020 = -4;
hidegree_y_2020 = -4;
if (q3_10d_2020 > -4 & q3_10d_2020 ~= 0) then do;
  hidegree_2020 = q3_10d_2020;
  hidegree_m_2020 = q3_10e_m_2020;
  hidegree_y_2020 = q3_10e_y_2020;
  end;
else if (q3_10b_2020 > -4 & q3_10b_2020 ~= 0) then do;
  hidegree_2020 = q3_10b_2020;
  hidegree_m_2020 = q3_10c_m_2020;
  hidegree_y_2020 = q3_10c_y_2020;
  end;
/*************************************/
/*  adjust years for y2k compliance  */
/*************************************/
if (hidegree_y_1979 > 0 & hidegree_y_1979 < 100) then hidegree_y_1979 = (hidegree_y_1979 + 1900);
if (hidegree_y_1980 > 0 & hidegree_y_1980 < 100) then hidegree_y_1980 = (hidegree_y_1980 + 1900);
if (hidegree_y_1981 > 0 & hidegree_y_1981 < 100) then hidegree_y_1981 = (hidegree_y_1981 + 1900);
if (hidegree_y_1982 > 0 & hidegree_y_1982 < 100) then hidegree_y_1982 = (hidegree_y_1982 + 1900);
if (hidegree_y_1983 > 0 & hidegree_y_1983 < 100) then hidegree_y_1983 = (hidegree_y_1983 + 1900);
if (hidegree_y_1984 > 0 & hidegree_y_1984 < 100) then hidegree_y_1984 = (hidegree_y_1984 + 1900);
if (hidegree_y_1985 > 0 & hidegree_y_1985 < 100) then hidegree_y_1985 = (hidegree_y_1985 + 1900);
if (hidegree_y_1986 > 0 & hidegree_y_1986 < 100) then hidegree_y_1986 = (hidegree_y_1986 + 1900);
if (hidegree_y_1987 > 0 & hidegree_y_1987 < 100) then hidegree_y_1987 = (hidegree_y_1987 + 1900);
if (hidegree_y_1988 > 0 & hidegree_y_1988 < 100) then hidegree_y_1988 = (hidegree_y_1988 + 1900);
if (hidegree_y_1989 > 0 & hidegree_y_1989 < 100) then hidegree_y_1989 = (hidegree_y_1989 + 1900);
if (hidegree_y_1990 > 0 & hidegree_y_1990 < 100) then hidegree_y_1990 = (hidegree_y_1990 + 1900);
if (hidegree_y_1991 > 0 & hidegree_y_1991 < 100) then hidegree_y_1991 = (hidegree_y_1991 + 1900);
if (hidegree_y_1992 > 0 & hidegree_y_1992 < 100) then hidegree_y_1992 = (hidegree_y_1992 + 1900);
if (hidegree_y_1993 > 0 & hidegree_y_1993 < 100) then hidegree_y_1993 = (hidegree_y_1993 + 1900);
if (hidegree_y_1994 > 0 & hidegree_y_1994 < 100) then hidegree_y_1994 = (hidegree_y_1994 + 1900);
if (hidegree_y_1996 > 0 & hidegree_y_1996 < 100) then hidegree_y_1996 = (hidegree_y_1996 + 1900);
if (hidegree_y_1998 > 0 & hidegree_y_1998 < 100) then hidegree_y_1998 = (hidegree_y_1998 + 1900);
if (hidegree_y_2000 > 0 & hidegree_y_2000 < 100) then hidegree_y_2000 = (hidegree_y_2000 + 1900);
if (hidegree_y_2002 > 0 & hidegree_y_2002 < 100) then hidegree_y_2002 = (hidegree_y_2002 + 1900);
if (hidegree_y_2004 > 0 & hidegree_y_2004 < 100) then hidegree_y_2004 = (hidegree_y_2004 + 1900);
if (hidegree_y_2006 > 0 & hidegree_y_2006 < 100) then hidegree_y_2006 = (hidegree_y_2006 + 1900);
if (hidegree_y_2008 > 0 & hidegree_y_2008 < 100) then hidegree_y_2008 = (hidegree_y_2008 + 1900);
if (hidegree_y_2010 > 0 & hidegree_y_2010 < 100) then hidegree_y_2010 = (hidegree_y_2010 + 1900);
if (hidegree_y_2012 > 0 & hidegree_y_2012 < 100) then hidegree_y_2012 = (hidegree_y_2012 + 1900);
if (hidegree_y_2014 > 0 & hidegree_y_2014 < 100) then hidegree_y_2014 = (hidegree_y_2014 + 1900);
if (hidegree_y_2016 > 0 & hidegree_y_2016 < 100) then hidegree_y_2016 = (hidegree_y_2016 + 1900);
if (hidegree_y_2018 > 0 & hidegree_y_2018 < 100) then hidegree_y_2018 = (hidegree_y_2018 + 1900);
if (hidegree_y_2020 > 0 & hidegree_y_2020 < 100) then hidegree_y_2020 = (hidegree_y_2020 + 1900);
/*********************************************/
/*     compute highest_degree_ever/_m_y   */
/*********************************************/
highest_degree_ever = -4;
highest_degree_ever_m = -4;
highest_degree_ever_y = -4;
highest_degree_ever_rept_y = -4;
if (hidegree_1979 > -4 & hidegree_1979 ~= 8) then do;
    highest_degree_ever = hidegree_1979;
    highest_degree_ever_m = hidegree_m_1979;
    highest_degree_ever_y = hidegree_y_1979;
    highest_degree_ever_rept_y = 1979;
end;
if (hidegree_1980 > -4 & hidegree_1980 > highest_degree_ever & hidegree_1980 ~= 8) then do;
    highest_degree_ever = hidegree_1980;
    highest_degree_ever_m = hidegree_m_1980;
    highest_degree_ever_y = hidegree_y_1980;
    highest_degree_ever_rept_y = 1980;
end;
if (hidegree_1981 > -4 & hidegree_1981 > highest_degree_ever & hidegree_1981 ~= 8) then do;
    highest_degree_ever = hidegree_1981;
    highest_degree_ever_m = hidegree_m_1981;
    highest_degree_ever_y = hidegree_y_1981;
    highest_degree_ever_rept_y = 1981;
end;
if (hidegree_1982 > -4 & hidegree_1982 > highest_degree_ever & hidegree_1982 ~= 8) then do;
    highest_degree_ever = hidegree_1982;
    highest_degree_ever_m = hidegree_m_1982;
    highest_degree_ever_y = hidegree_y_1982;
    highest_degree_ever_rept_y = 1982;
end;
if (hidegree_1983 > -4 & hidegree_1983 > highest_degree_ever & hidegree_1983 ~= 8) then do;
    highest_degree_ever = hidegree_1983;
    highest_degree_ever_m = hidegree_m_1983;
    highest_degree_ever_y = hidegree_y_1983;
    highest_degree_ever_rept_y = 1983;
end;
if (hidegree_1984 > -4 & hidegree_1984 > highest_degree_ever & hidegree_1984 ~= 8) then do;
    highest_degree_ever = hidegree_1984;
    highest_degree_ever_m = hidegree_m_1984;
    highest_degree_ever_y = hidegree_y_1984;
    highest_degree_ever_rept_y = 1984;
end;
if (hidegree_1985 > -4 & hidegree_1985 > highest_degree_ever & hidegree_1985 ~= 8) then do;
    highest_degree_ever = hidegree_1985;
    highest_degree_ever_m = hidegree_m_1985;
    highest_degree_ever_y = hidegree_y_1985;
    highest_degree_ever_rept_y = 1985;
end;
if (hidegree_1986 > -4 & hidegree_1986 > highest_degree_ever & hidegree_1986 ~= 8) then do;
    highest_degree_ever = hidegree_1986;
    highest_degree_ever_m = hidegree_m_1986;
    highest_degree_ever_y = hidegree_y_1986;
    highest_degree_ever_rept_y = 1986;
end;
if (hidegree_1987 > -4 & hidegree_1987 > highest_degree_ever & hidegree_1987 ~= 8) then do;
    highest_degree_ever = hidegree_1987;
    highest_degree_ever_m = hidegree_m_1987;
    highest_degree_ever_y = hidegree_y_1987;
    highest_degree_ever_rept_y = 1987;
end;
if (hidegree_1988 > -4 & hidegree_1988 > highest_degree_ever & hidegree_1988 ~= 8) then do;
    highest_degree_ever = hidegree_1988;
    highest_degree_ever_m = hidegree_m_1988;
    highest_degree_ever_y = hidegree_y_1988;
    highest_degree_ever_rept_y = 1988;
end;
if (hidegree_1989 > -4 & hidegree_1989 > highest_degree_ever & hidegree_1989 ~= 8) then do;
    highest_degree_ever = hidegree_1989;
    highest_degree_ever_m = hidegree_m_1989;
    highest_degree_ever_y = hidegree_y_1989;
    highest_degree_ever_rept_y = 1989;
end;
if (hidegree_1990 > -4 & hidegree_1990 > highest_degree_ever & hidegree_1990 ~= 8) then do;
    highest_degree_ever = hidegree_1990;
    highest_degree_ever_m = hidegree_m_1990;
    highest_degree_ever_y = hidegree_y_1990;
    highest_degree_ever_rept_y = 1990;
end;
if (hidegree_1991 > -4 & hidegree_1991 > highest_degree_ever & hidegree_1991 ~= 8) then do;
    highest_degree_ever = hidegree_1991;
    highest_degree_ever_m = hidegree_m_1991;
    highest_degree_ever_y = hidegree_y_1991;
    highest_degree_ever_rept_y = 1991;
end;
if (hidegree_1992 > -4 & hidegree_1992 > highest_degree_ever & hidegree_1992 ~= 8) then do;
    highest_degree_ever = hidegree_1992;
    highest_degree_ever_m = hidegree_m_1992;
    highest_degree_ever_y = hidegree_y_1992;
end;
if (hidegree_1993 > -4 & hidegree_1993 > highest_degree_ever & hidegree_1993 ~= 8) then do;
    highest_degree_ever = hidegree_1993;
    highest_degree_ever_m = hidegree_m_1993;
    highest_degree_ever_y = hidegree_y_1993;
    highest_degree_ever_rept_y = 1993;
end;
if (hidegree_1994 > -4 & hidegree_1994 > highest_degree_ever & hidegree_1994 ~= 8) then do;
    highest_degree_ever = hidegree_1994;
    highest_degree_ever_m = hidegree_m_1994;
    highest_degree_ever_y = hidegree_y_1994;
    highest_degree_ever_rept_y = 1994;
end;
if (hidegree_1996 > -4 & hidegree_1996 > highest_degree_ever & hidegree_1996 ~= 8) then do;
    highest_degree_ever = hidegree_1996;
    highest_degree_ever_m = hidegree_m_1996;
    highest_degree_ever_y = hidegree_y_1996;
    highest_degree_ever_rept_y = 1996;
end;
if (hidegree_1998 > -4 & hidegree_1998 > highest_degree_ever & hidegree_1998 ~= 8) then do;
    highest_degree_ever = hidegree_1998;
    highest_degree_ever_m = hidegree_m_1998;
    highest_degree_ever_y = hidegree_y_1998;
    highest_degree_ever_rept_y = 1998;
end;
if (hidegree_2000 > -4 & hidegree_2000 > highest_degree_ever & hidegree_2000 ~= 8) then do;
    highest_degree_ever = hidegree_2000;
    highest_degree_ever_m = hidegree_m_2000;
    highest_degree_ever_y = hidegree_y_2000;
    highest_degree_ever_rept_y = 2000;
end;
if (hidegree_2002 > -4 & hidegree_2002 > highest_degree_ever & hidegree_2002 ~= 8) then do;
    highest_degree_ever = hidegree_2002;
    highest_degree_ever_m = hidegree_m_2002;
    highest_degree_ever_y = hidegree_y_2002;
    highest_degree_ever_rept_y = 2002;
end;
if (hidegree_2004 > -4 & hidegree_2004 > highest_degree_ever & hidegree_2004 ~= 8) then do;
    highest_degree_ever = hidegree_2004;
    highest_degree_ever_m = hidegree_m_2004;
    highest_degree_ever_y = hidegree_y_2004;
    highest_degree_ever_rept_y = 2004;
end;
if (hidegree_2006 > -4 & hidegree_2006 > highest_degree_ever & hidegree_2006 ~= 8) then do;
    highest_degree_ever = hidegree_2006;
    highest_degree_ever_m = hidegree_m_2006;
    highest_degree_ever_y = hidegree_y_2006;
    highest_degree_ever_rept_y = 2006;
end;
if (hidegree_2008 > -4 & hidegree_2008 > highest_degree_ever & hidegree_2008 ~= 8) then do;
    highest_degree_ever = hidegree_2008;
    highest_degree_ever_m = hidegree_m_2008;
    highest_degree_ever_y = hidegree_y_2008;
    highest_degree_ever_rept_y = 2008;
end;
if (hidegree_2010 > -4 & hidegree_2010 > highest_degree_ever & hidegree_2010 ~= 8) then do;
    highest_degree_ever = hidegree_2010;
    highest_degree_ever_m = hidegree_m_2010;
    highest_degree_ever_y = hidegree_y_2010;
    highest_degree_ever_rept_y = 2010;
end;
if (hidegree_2012 > -4 & hidegree_2012 > highest_degree_ever & hidegree_2012 ~= 8) then do;
    highest_degree_ever = hidegree_2012;
    highest_degree_ever_m = hidegree_m_2012;
    highest_degree_ever_y = hidegree_y_2012;
    highest_degree_ever_rept_y = 2012;
end;
if (hidegree_2014 > -4 & hidegree_2014 > highest_degree_ever & hidegree_2014 ~= 8) then do;
    highest_degree_ever = hidegree_2014;
    highest_degree_ever_m = hidegree_m_2014;
    highest_degree_ever_y = hidegree_y_2014;
    highest_degree_ever_rept_y = 2014;
end;
if (hidegree_2016 > -4 & hidegree_2016 > highest_degree_ever & hidegree_2016 ~= 8) then do;
    highest_degree_ever = hidegree_2016;
    highest_degree_ever_m = hidegree_m_2016;
    highest_degree_ever_y = hidegree_y_2016;
    highest_degree_ever_rept_y = 2016;
end;
if (hidegree_2018 > -4 & hidegree_2018 > highest_degree_ever & hidegree_2018 ~= 8) then do;
    highest_degree_ever = hidegree_2018;
    highest_degree_ever_m = hidegree_m_2018;
    highest_degree_ever_y = hidegree_y_2018;
    highest_degree_ever_rept_y = 2018;
end;
if (hidegree_2020 > -4 & hidegree_2020 > highest_degree_ever & hidegree_2020 ~= 8) then do;
    highest_degree_ever = hidegree_2020;
    highest_degree_ever_m = hidegree_m_2020;
    highest_degree_ever_y = hidegree_y_2020;
    highest_degree_ever_rept_y = 2020;
end;
if (highest_degree_ever = 8 & highest_degree_ever = -4) then do;
   highest_degree_ever = highest_degree_ever;
   highest_degree_ever_m = highest_degree_ever_m;
   highest_degree_ever_y = highest_degree_ever_y;
   highest_degree_ever_rept_y = highest_degree_ever_rept_y;
end;
if (highest_degree_ever_y > 0 & highest_degree_ever_y < 100) then highest_degree_ever_y = (highest_degree_ever_y + 1900);
/*********************************************/
/*     fill in missing (-3) dates            */
/*********************************************/
do m = 1 to 29;
 if (highest_degree_ever_y in(-1, -2, -3)) then do;
    if (hidegreeeach_y_1979 > 0) then do;
     highest_degree_ever_m = hidegree_m_1979;
     highest_degree_ever_y = hidegree_y_1979;
     end;
    else if (hidegreeeach_y_1980 > 0) then do;
     highest_degree_ever_m = hidegree_m_1980;
     highest_degree_ever_y = hidegree_y_1980;
     end;
    else if (hidegreeeach_y_1981 > 0) then do;
     highest_degree_ever_m = hidegree_m_1981;
     highest_degree_ever_y = hidegree_y_1981;
     end;
    else if (hidegreeeach_y_1982 > 0) then do;
     highest_degree_ever_m = hidegree_m_1982;
     highest_degree_ever_y = hidegree_y_1982;
     end;
    else if (hidegreeeach_y_1983 > 0) then do;
     highest_degree_ever_m = hidegree_m_1983;
     highest_degree_ever_y = hidegree_y_1983;
     end;
    else if (hidegreeeach_y_1984 > 0) then do;
     highest_degree_ever_m = hidegree_m_1984;
     highest_degree_ever_y = hidegree_y_1984;
     end;
    else if (hidegreeeach_y_1985 > 0) then do;
     highest_degree_ever_m = hidegree_m_1985;
     highest_degree_ever_y = hidegree_y_1985;
     end;
    else if (hidegreeeach_y_1986 > 0) then do;
     highest_degree_ever_m = hidegree_m_1986;
     highest_degree_ever_y = hidegree_y_1986;
     end;
    else if (hidegreeeach_y_1987 > 0) then do;
     highest_degree_ever_m = hidegree_m_1987;
     highest_degree_ever_y = hidegree_y_1987;
     end;
    else if (hidegreeeach_y_1988 > 0) then do;
     highest_degree_ever_m = hidegree_m_1988;
     highest_degree_ever_y = hidegree_y_1988;
     end;
    else if (hidegreeeach_y_1989 > 0) then do;
     highest_degree_ever_m = hidegree_m_1989;
     highest_degree_ever_y = hidegree_y_1989;
     end;
    else if (hidegreeeach_y_1990 > 0) then do;
     highest_degree_ever_m = hidegree_m_1990;
     highest_degree_ever_y = hidegree_y_1990;
     end;
    else if (hidegreeeach_y_1991 > 0) then do;
     highest_degree_ever_m = hidegree_m_1991;
     highest_degree_ever_y = hidegree_y_1991;
     end;
    else if (hidegreeeach_y_1992 > 0) then do;
     highest_degree_ever_m = hidegree_m_1992;
     highest_degree_ever_y = hidegree_y_1992;
     end;
    else if (hidegreeeach_y_1993 > 0) then do;
     highest_degree_ever_m = hidegree_m_1993;
     highest_degree_ever_y = hidegree_y_1993;
     end;
    else if (hidegreeeach_y_1994 > 0) then do;
     highest_degree_ever_m = hidegree_m_1994;
     highest_degree_ever_y = hidegree_y_1994;
     end;
    else if (hidegreeeach_y_1996 > 0) then do;
     highest_degree_ever_m = hidegree_m_1996;
     highest_degree_ever_y = hidegree_y_1996;
     end;
    else if (hidegreeeach_y_1998 > 0) then do;
     highest_degree_ever_m = hidegree_m_1998;
     highest_degree_ever_y = hidegree_y_1998;
     end;
    else if (hidegreeeach_y_2000 > 0) then do;
     highest_degree_ever_m = hidegree_m_2000;
     highest_degree_ever_y = hidegree_y_2000;
     end;
    else if (hidegreeeach_y_2002 > 0) then do;
     highest_degree_ever_m = hidegree_m_2002;
     highest_degree_ever_y = hidegree_y_2002;
     end;
    else if (hidegreeeach_y_2004 > 0) then do;
     highest_degree_ever_m = hidegree_m_2004;
     highest_degree_ever_y = hidegree_y_2004;
     end;
    else if (hidegreeeach_y_2006 > 0) then do;
     highest_degree_ever_m = hidegree_m_2006;
     highest_degree_ever_y = hidegree_y_2006;
     end;
    else if (hidegreeeach_y_2008 > 0) then do;
     highest_degree_ever_m = hidegree_m_2008;
     highest_degree_ever_y = hidegree_y_2008;
     end;
    else if (hidegreeeach_y_2010 > 0) then do;
     highest_degree_ever_m = hidegree_m_2010;
     highest_degree_ever_y = hidegree_y_2010;
     end;
    else if (hidegreeeach_y_2012 > 0) then do;
     highest_degree_ever_m = hidegree_m_2012;
     highest_degree_ever_y = hidegree_y_2012;
     end;
    else if (hidegreeeach_y_2014 > 0) then do;
     highest_degree_ever_m = hidegree_m_2014;
     highest_degree_ever_y = hidegree_y_2014;
     end;
    else if (hidegreeeach_y_2016 > 0) then do;
     highest_degree_ever_m = hidegree_m_2016;
     highest_degree_ever_y = hidegree_y_2016;
     end;
    else if (hidegreeeach_y_2018 > 0) then do;
     highest_degree_ever_m = hidegree_m_2018;
     highest_degree_ever_y = hidegree_y_2018;
     end;
    else if (hidegreeeach_y_2020 > 0) then do;
     highest_degree_ever_m = hidegree_m_2020;
     highest_degree_ever_y = hidegree_y_2020;
     end;
 end;
end;
/**************************************/
/*   write out final data             */
/**************************************/
data hidegreeever2022_final (keep=pubid highest_degree_ever);
endsas;
		
Subscribe to NLSY79