Skip to main content

NLSY79

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 (PDF) is available.

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

Click to 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: Data characteristics

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

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;
		

NLSY79 Appendix 7: Unemployment Rate

The NLSY79 unemployment rate variables are constructed using state and area labor force data from the May publication of Employment and Earnings for the month of March of each survey year. Employment and Earnings is published by the U.S. Department of Labor, Bureau of Labor Statistics and lists the civilian labor force and number of unemployed persons for every state and selected metropolitan areas.

The figures provided for the state and selected metropolitan and micropolitan statistical areas are used to compute the unemployment rate for the portion or balance of the state that is not represented in a metropolitan or micropolitan statistical area. If a respondent resides in a metropolitan or micropolitan area that is listed in Employment and Earnings, then the unemployment rate is the unemployment rate for that metropolitan or micropolitan area. Otherwise, the unemployment rate is the computed balance of state unemployment rate for the state in which the respondent resides.

From 1979-2002, the respondent's metropolitan statistical area was assigned based on the county, state, and zip code of current residence. Beginning in 2004, the metropolitan or micropolitan statistical area is assigned based on the latitude and longitude of current residence. (For a detailed discussion of the hand-editing and merging process with other data files used to create the geographic variables, including the metropolitan statistical area, see Appendix 10: Geocode Documentation.)

As with other geographic based variables, respondents who are in the military, who are living outside of the United States, or who have invalid geographic data for a given survey year are valid skips on these variables.

The geocode data files contain the continuous unemployment rate as it was calculated for the area of residence.

NLSY79 Appendix 6: Urban-Rural and SMSA-Central City Variables

1979-1996 Urban-Rural Residence

Through 1996, the NLSY79 Urban-Rural Residence variables were constructed using the total and urban population data for the county of residence from the 1970 Census of Population Characteristics of the Population (for NLSY79 1979-1982) and from the 1980 Census of Population and Housing (for NLSY79 1983-1988). These data are included in the 1977 and 1983 County and City Data Book data files respectively.

The urban population consists of all inhabitants of urbanized areas. An urbanized area is defined as a central core or city and its adjacent, closely settled territory which have a combined total population of 50,000 or more (with exceptions in Alaska, New York, the New England states, and Wisconsin). These definitions have remained largely unchanged since 1950. For more detailed definitions and comments on exceptions, refer to the U.S. Bureau of the Census 1970/1980 Census of Population, Characteristics of the Population, Number of Inhabitants (Series PC80-1-A).

Calculation of the 1979-96 NLSY79 Urban-Rural Residence variables involved the following two steps:

  1. The percent of urban population was calculated by dividing the urban population of the county by the total county population and multiplying by 100.
  2. Rural counties for the NLSY79 variables were defined as those with between 0-49% urban population. Urban counties were defined as those with 50% or more urban population.

1998-2006 Urban-Rural Residence

Beginning with the 1998 release, the information needed to calculate whether the county was urban/rural was no longer available in the County and City Data Book releases. For 1998, a respondent is coded urban if living in an urbanized area or in a place with greater than 2500 population. There is no regard to county.

2008-2022 Urban-Rural Residence

For 2008-2022, the Urban/Rural variable is created using the definition of the US Census Bureau. A respondent is coded urban if living in an Urbanized Area or an Urban Cluster. All other respondents are considered rural. Respondents with quality of match of short street, long street or zip centroid are evaluated before assigning the urban/rural code. If the entire street or zip code falls within an area that fits the urban definition, the respondent is assigned an urban code. If the entire street or zip code falls within an area defined as rural, the respondent is assigned a rural code. If the street or zip code crosses an urban/rural boundary, the respondent is assigned an unknown code.

Non-interview respondents were assigned a valued of -5. Respondents who were residing outside of the United States were assigned a value of -4. Respondents who latitude and longitude of the current residence could not be determined were assigned a valued of -3.

Important information: Calculating urban vs. rural

The method of calculating urban vs. rural prior to the 1998 data release designated an entire county as either urban or rural. For example, if a county contained multiple respondents, some living in an urban-like area and others in rural areas, they all received the same designation depending on the degree of urbanization of the county of residence. In 1998-2006, the method of calculating urban/rural allows a respondent living in a rural area of a county to be coded rural, while another respondent in an urban area of that same county can be coded urban. The net effect appears to be an increase in respondents living in rural areas.

For all survey years, non-interview cases are set to a -5 value on the Urban-Rural Residence variable. All other missing cases are valid skips on these variables.

For a detailed discussion of the procedures used for hand-editing and merging respondent data with other data in creating the geographic variables, see Appendix 10: Geocode Documentation in the NLSY79 Geocode Codebook Supplement.

1979-2022 SMSA-Central City variables

The NLSY79 SMSA-Central City variables are constructed using data for the SMSA/MSA and Place Description (PD) included in the City Reference File (CRF) data files. The 1973 CRF was used for NLSY79 1979-1982 SMSA-Central City variables; the 1982 CRF was used for 1983 variables; 1983 CRF was used for 1984-1987 variables; the 1987 CRF was used for the 1988-1992 variables; and the 1992 CRF was used for the 1993-1998 variables. See below for information on the 2000-2022 variables. (For a more detailed discussion of changes in official terminology and geographic designations and comparability across years, see Appendix 10: Geocode Documentation in the NLSY79 Geocode Codebook Supplement.)

1979-1998 SMSA-Central City Residence

Through 1998, calculation of the SMSA-Central City Residence variables involved the following two steps:

  1. A respondent's SMSA/MSA and PD were assigned based on the county, state, and zip code of current residence. (For a detailed discussion of the procedures used for hand-editing and merging respondent data with other data in creating the geographic variables, including the SMSA/MSA, see Appendix 10: Geocode Documentation in the NLSY79 Geocode Codebook Supplement.)
  2. Based on their PD and SMSA/MSAs, respondents were assigned to one of the following categories:
  • Respondents not residing in an SMSA/MSA were defined as "not in SMSA."
  • Respondents residing in an SMSA/MSA, but not in a central city of an SMSA/MSA according to the PD, were defined as "SMSA, not central city."
  • Respondents for whom the PD leads to an ambiguous central city residence status were defined as "SMSA, central city not known." These cases generally resulted from zip codes that cover more than one geographically-defined area.
  • Respondents residing in both an SMSA/MSA and the central city of an SMSA/MSA according to the PD were defined as "SMSA in central city."

Non-interview respondents were assigned a value of -5. Respondents with an ambiguous SMSA/MSA residence status or missing values for reasons other than non-interview are valid skips on these variables.

2000-2002 SMSA-Central City Residence

Beginning with the 2000 release, the calculation of the central city variable was revised slightly. The process still consists of two components. The first delineation is MSA/non-MSA residence. For respondents in an MSA, the residence is further defined by placement inside or outside a central city as defined by the Census Bureau.

Respondents who live in an MSA who have a quality of match code of either manual edit or zip centroid are evaluated before assigning the central city code. If the street (manual edit match) or the zip code area (zip centroid match) falls entirely within the boundaries of the central city they are coded as central city. If the street or zip code area fall completely outside the central city boundary, they are coded as not in a central city. Otherwise, these respondents are coded as central city unknown.

A further complication is that Maptitude, the software currently being used, does not include central city boundary files for several areas. Regardless of quality of match code, respondents in those areas are coded as being in a MSA with an unknown central city status since the mailing address is insufficient to reveal whether the respondent resides within the central city boundaries. When updates of Maptitude are available, the city boundaries will be updated.

2004-2022 CBSA-Principal City Residence

The 2004-2022 CBSA-principal city variables were constructed using data for the CBSA (Core Based Statistical Area) and principal city. The creation of principal city variables involved the following two steps:

  1. A respondent's CBSA and principal city were assigned based on the latitude and longitude of the current residence (For more detailed discussion of the procedures, see Appendix 10: Geocode Documentation in the NLSY Geocode Codebook Supplement)
  2. Based on their CBSA and principal city residence, respondents were assigned to one of the following categories:
  • Respondents not residing in an CBSA were coded as "not in CBSA"
  • Respondents residing in a CBSA but not in a principal city of a CBSA were coded as "CBSA, not in principal city"
  • Respondents residing in both a CBSA and a principal city were coded as "CBSA, in principal city"
  • Respondents with an ambiguous CBSA or principal city residence status were coded as"CBSA, central city unknown." These cases generally resulted from street or zip code that covers more than one geographically-defined area.

Respondents who have a quality of match code of either manual edit or zip centroid are evaluated before assigning the CBSA-principal city code. If the street (manual edit match) or the zip code area (zip centroid match) falls entirely outside the boundaries of the CBSA, they are coded as"not in CBSA." If the street or zip code area falls entirely within the boundaries of the CBSA and the principal city they are coded as"CBSA, in a principal city." If the street or zip code area falls completely within the boundary of the CBSA but outside the principal city boundary, they are coded as "CBSA, not in a principal city." Otherwise, these respondents are coded as "CBSA, principal city unknown."

Non-interviewed respondents were assigned a valued of -5. Respondents who were residing outside of the United States were assigned a value of -4. Respondents for whom latitude and longitude of the current residence could not be determined were assigned a value of -3.

Subscribe to NLSY79