/******************************************************************************************** * * Variables created: CVC_UI_EVER * * CVC_UI_YR.1980 - CVC_UI_YR.2018 * * CVC_AMT_UI_YR.1980 - CVC_AMT_UI_YR.2018 * * CVC_UI_SPELLS_YR.1980 - CVC_UI_SPELLS_YR.2018 * * ** * * Created Variable names on CD CVC names in this program * * CVC_UI_EVER CUIEV * * CVC_UI_YR.XXXX CUIRXXXX * * CVC_AMT_UI_YR.XXXX CUIAXXXX * * CVC_UI_SPELLS_YR.XXXX CUISXXXX * ********************************************************************************************/ *******************************************************************************************************; /**Variable Names on the Gator Variable Names in the Program**********************************; CVC_UI_SPELLS_YR.00_XRND CVCUIS_R18_2000 CVC_UI_SPELLS_YR.01_XRND CVCUIS_R18_2001 CVC_UI_SPELLS_YR.02_XRND CVCUIS_R18_2002 CVC_UI_SPELLS_YR.03_XRND CVCUIS_R18_2003 CVC_UI_SPELLS_YR.04_XRND CVCUIS_R18_2004 CVC_UI_SPELLS_YR.05_XRND CVCUIS_R18_2005 CVC_UI_SPELLS_YR.06_XRND CVCUIS_R18_2006 CVC_UI_SPELLS_YR.07_XRND CVCUIS_R18_2007 CVC_UI_SPELLS_YR.08_XRND CVCUIS_R18_2008 CVC_UI_SPELLS_YR.09_XRND CVCUIS_R18_2009 CVC_UI_SPELLS_YR.10_XRND CVCUIS_R18_2010 CVC_UI_SPELLS_YR.11_XRND CVCUIS_R18_2011 CVC_UI_SPELLS_YR.12_XRND CVCUIS_R18_2012 CVC_UI_SPELLS_YR.13_XRND CVCUIS_R18_2013 CVC_UI_SPELLS_YR.14_XRND CVCUIS_R18_2014 CVC_UI_SPELLS_YR.15_XRND CVCUIS_R18_2015 CVC_UI_SPELLS_YR.16_XRND CVCUIS_R18_2016 CVC_UI_SPELLS_YR.17_XRND CVCUIS_R18_2017 CVC_UI_SPELLS_YR.18_XRND CVCUIS_R18_2018 CVC_UI_SPELLS_YR.97_XRND CVCUIS_R18_1997 CVC_UI_SPELLS_YR.98_XRND CVCUIS_R18_1998 CVC_UI_SPELLS_YR.99_XRND CVCUIS_R18_1999 CVC_UI_EVER_XRND CVCUIEV_R18 CVC_UI_YR.00_XRND CVCUIR_R18_2000 CVC_UI_YR.01_XRND CVCUIR_R18_2001 CVC_UI_YR.02_XRND CVCUIR_R18_2002 CVC_UI_YR.03_XRND CVCUIR_R18_2003 CVC_UI_YR.04_XRND CVCUIR_R18_2004 CVC_UI_YR.05_XRND CVCUIR_R18_2005 CVC_UI_YR.06_XRND CVCUIR_R18_2006 CVC_UI_YR.07_XRND CVCUIR_R18_2007 CVC_UI_YR.08_XRND CVCUIR_R18_2008 CVC_UI_YR.09_XRND CVCUIR_R18_2009 CVC_UI_YR.10_XRND CVCUIR_R18_2010 CVC_UI_YR.11_XRND CVCUIR_R18_2011 CVC_UI_YR.12_XRND CVCUIR_R18_2012 CVC_UI_YR.13_XRND CVCUIR_R18_2013 CVC_UI_YR.14_XRND CVCUIR_R18_2014 CVC_UI_YR.15_XRND CVCUIR_R18_2015 CVC_UI_YR.16_XRND CVCUIR_R18_2016 CVC_UI_YR.17_XRND CVCUIR_R18_2017 CVC_UI_YR.18_XRND CVCUIR_R18_2018 CVC_UI_YR.97_XRND CVCUIR_R18_1997 CVC_UI_YR.98_XRND CVCUIR_R18_1998 CVC_UI_YR.99_XRND CVCUIR_R18_1999 CVC_AMT_UI_YR.00_XRND CVCUIA_R18_2000 CVC_AMT_UI_YR.01_XRND CVCUIA_R18_2001 CVC_AMT_UI_YR.02_XRND CVCUIA_R18_2002 CVC_AMT_UI_YR.03_XRND CVCUIA_R18_2003 CVC_AMT_UI_YR.04_XRND CVCUIA_R18_2004 CVC_AMT_UI_YR.05_XRND CVCUIA_R18_2005 CVC_AMT_UI_YR.06_XRND CVCUIA_R18_2006 CVC_AMT_UI_YR.07_XRND CVCUIA_R18_2007 CVC_AMT_UI_YR.08_XRND CVCUIA_R18_2008 CVC_AMT_UI_YR.09_XRND CVCUIA_R18_2009 CVC_AMT_UI_YR.10_XRND CVCUIA_R18_2010 CVC_AMT_UI_YR.11_XRND CVCUIA_R18_2011 CVC_AMT_UI_YR.12_XRND CVCUIA_R18_2012 CVC_AMT_UI_YR.13_XRND CVCUIA_R18_2013 CVC_AMT_UI_YR.14_XRND CVCUIA_R18_2014 CVC_AMT_UI_YR.15_XRND CVCUIA_R18_2015 CVC_AMT_UI_YR.16_XRND CVCUIA_R18_2016 CVC_AMT_UI_YR.17_XRND CVCUIA_R18_2017 CVC_AMT_UI_YR.18_XRND CVCUIA_R18_2018 CVC_AMT_UI_YR.97_XRND CVCUIA_R18_1997 CVC_AMT_UI_YR.98_XRND CVCUIA_R18_1998 CVC_AMT_UI_YR.99_XRND CVCUIA_R18_1999 SYMBOL_CURDATE~D_2019 INTD SYMBOL_CURDATE~M_2019 INTM SYMBOL_CURDATE~Y_2019 INTY All YPRG variables are from the current round. ******************************************************************************************************* *******************************************************************************************************/ /* Start of program code */ data nonint; merge uin19.in_C_uiR19 (keep=pubid YPRG_1830_UPD) uin19.in_P_uiR19 (keep=pubid cvcui:); by pubid; if YPRG_1830_UPD in (-5,-4); array CUIR CUIR1980-CUIR2020; array CUIA CUIA1980-CUIA2020; array CUIS CUIS1980-CUIS2020; array cvcuir cvcuir_r18_1980 - cvcuir_r18_2018; array cvcuia cvcuia_r18_1980 - cvcuia_r18_2018; array cvcuis cvcuis_r18_1980 - cvcuis_r18_2018; do i=1 to dim(cvcuir); CUIR(i)=cvcuir(i); CUIA(i)=cvcuia(i); CUIS(i)=cvcuis(i); end; /* initialize "total months of unemp ever received" to last round CVC.*/ CUIEV=CVCUIEV_r18; /* non-interviewers would not have information for latest year of current round*/ CUIR2019=-4; CUIR2020=-4; CUIA2019=-4; CUIA2020=-4; CUIS2019=-4; CUIS2020=-4; /* check data consistency problem by flag dataprb10. Initialize the value to zero.*/ dataprb10=0; do j=1 to dim(CUIA) while (dataprb10=0); if CUIR(j) in (-4,0) & CUIA(j) not in (.,-4) then dataprb10=j+0.1; else if CUIR(j)=-3 & CUIA(j)~=-3 then dataprb10=j+0.2; else if 1<=CUIR(j)<=12 & CUIA(j) in (.,-4) then dataprb10=j+0.3; if ( CUIR(j)=-3 | CUIR(j)>=1 ) & CUIS(j)=-4 then dataprb10=max(j,dataprb10)+0.01; if CUIS(j)>=1 & CUIA(j)=-4 then dataprb10=max(j,dataprb10)+0.001; if CUIR(j)>-4 & CUIEV in (., -4) then dataprb10=max(j,dataprb10)+0.0001; else if -40 then do; _tempsum = _tempsum+CUIR(j); if _tempsum>CUIEV>0 then dataprb10=max(j,dataprb10)+0.0003; end; end; run; data int; merge uin19.in_C_uiR19 uin19.in_P_uiR19 (drop=unemp:); /*uin15.in_P_uiR15 (keep=pubid bdate:);*/ by pubid; if YPRG_1830_UPD>-4; /******************************************************************************************/ /*** Define all the arrays used in this program. ****/ /******************************************************************************************/ /* (1) variables from previous rounds. */ array intdR CV_INTERVIEW_DATE_D_1997 - CV_INTERVIEW_DATE_D_2011 CV_INTERVIEW_DATE_D_2013 CV_INTERVIEW_DATE_D_2015 CV_INTERVIEW_DATE_D_2017; array intmR CV_INTERVIEW_DATE_M_1997 - CV_INTERVIEW_DATE_M_2011 CV_INTERVIEW_DATE_M_2013 CV_INTERVIEW_DATE_M_2015 CV_INTERVIEW_DATE_M_2017; array intyR CV_INTERVIEW_DATE_Y_1997 - CV_INTERVIEW_DATE_Y_2011 CV_INTERVIEW_DATE_Y_2013 CV_INTERVIEW_DATE_Y_2015 CV_INTERVIEW_DATE_Y_2017; array cvcuir cvcuir_r18_1980 - cvcuir_r18_2018; array cvcuia cvcuia_r18_1980 - cvcuia_r18_2018; array cvcuis cvcuis_r18_1980 - cvcuis_r18_2018; /* (2) (Raw data) Information available from current round.*/ /* START YEAR, MONTH, ACTUAL DAY and ESTIMATED DAY information. */ array ys (8) YPRG_4000_UPD_01_Y YPRG_4000_UPD_02_Y YPRG_4000_UPD_03_Y YPRG_4000_UPD_04_Y YPRG_4000_01_Y YPRG_4000_02_Y YPRG_4000_03_Y YPRG_4000_04_Y; array ms (8) YPRG_4000_UPD_01_M YPRG_4000_UPD_02_M YPRG_4000_UPD_03_M YPRG_4000_UPD_04_M YPRG_4000_01_M YPRG_4000_02_M YPRG_4000_03_M YPRG_4000_04_M; array ds (8) YPRG_4200_UPD_01 YPRG_4200_UPD_02 YPRG_4200_UPD_03 YPRG_4200_UPD_04 YPRG_4200_01 YPRG_4200_02 YPRG_4200_03 YPRG_4200_04; array es (8) YPRG_4300_UPD_01 YPRG_4300_UPD_02 YPRG_4300_UPD_03 YPRG_4300_UPD_04 YPRG_4300_01 YPRG_4300_02 YPRG_4300_03 YPRG_4300_04; /* END YEAR, MONTH, ACTUAL DAY and ESTIMATED DAY information.; */ array ye (8) YPRG_4700_UPD_01_Y YPRG_4700_UPD_02_Y YPRG_4700_UPD_03_Y YPRG_4700_UPD_04_Y YPRG_4700_01_Y YPRG_4700_02_Y YPRG_4700_03_Y YPRG_4700_04_Y; array me (8) YPRG_4700_UPD_01_M YPRG_4700_UPD_02_M YPRG_4700_UPD_03_M YPRG_4700_UPD_04_M YPRG_4700_01_M YPRG_4700_02_M YPRG_4700_03_M YPRG_4700_04_M; array de (8) YPRG_4900_UPD_01 YPRG_4900_UPD_02 YPRG_4900_UPD_03 YPRG_4900_UPD_04 YPRG_4900_01 YPRG_4900_02 YPRG_4900_03 YPRG_4900_04; array ee (8) YPRG_5000_UPD_01 YPRG_5000_UPD_02 YPRG_5000_UPD_03 YPRG_5000_UPD_04 YPRG_5000_01 YPRG_5000_02 YPRG_5000_03 YPRG_5000_04; /* ESTIMATED WEEKS - unable to answer start or stop date questions.; */ array wks (8) YPRG_5200_UPD_01 YPRG_5200_UPD_02 YPRG_5200_UPD_03 YPRG_5200_UPD_04 YPRG_5200_01 YPRG_5200_02 YPRG_5200_03 YPRG_5200_04; /* Weekly AMOUNT RECEIVED - actual & estimated.; */ array incm (8) YPRG_5900_UPD_01 YPRG_5900_UPD_02 YPRG_5900_UPD_03 YPRG_5900_UPD_04 YPRG_5900_01 YPRG_5900_02 YPRG_5900_03 YPRG_5900_04; array eincm (8) YPRG_6000_UPD_01 YPRG_6000_UPD_02 YPRG_6000_UPD_03 YPRG_6000_UPD_04 YPRG_6000_01 YPRG_6000_02 YPRG_6000_03 YPRG_6000_04; /* STOPPED FOR 2+ WEEKS.; */ array stpgp (8) YPRG_4500_UPD_01 YPRG_4500_UPD_02 YPRG_4500_UPD_03 YPRG_4500_UPD_04 YPRG_4500_01 YPRG_4500_02 YPRG_4500_03 YPRG_4500_04; /* RECEIVE AGAIN? */ array recag (8) YPRG_6300_UPD_01 YPRG_6300_UPD_02 YPRG_6300_UPD_03 YPRG_6300_UPD_04 YPRG_6300_01 YPRG_6300_02 YPRG_6300_03 YPRG_6300_04; /* CURRENTLY RECEIVING information, For NVPR (Never Prior) sections */ array cur (8) YPRG_4400_UPD_01 YPRG_4400_UPD_02 YPRG_4400_UPD_03 YPRG_4400_UPD_04 YPRG_4400_01 YPRG_4400_02 YPRG_4400_03 YPRG_4400_04; array cwks (8) YPRG_1930_UPD YPRG_1930_UPD YPRG_1930_UPD YPRG_1930_UPD YPRG_3500 YPRG_3500 YPRG_3500 YPRG_3500; /* RECEIVING at DLI.*/ array dli (8) YPRG_3901_UPD_01 dum dum dum dum dum dum dum; /* (3) Variables to be created. */ /* CVC variables to be created*/ array CUIR CUIR1980-CUIR2020; array CUIA CUIA1980-CUIA2020; array CUIS CUIS1980-CUIS2020; /* csm, cem, efl, UIREC, & UIAMT are event history variables. */ array UIREC UIREC001-UIREC492; /* indicator for receipt, monthly. */ array UIAMT UIAMT001-UIAMT492; /* amount received, monthly. */ array csm (8) csmu11-csmu14 csmu21-csmu24; /* start date in CMS. */ array cem (8) cemu11-cemu14 cemu21-cemu24; /* stop date in CMS. */ array efl (8) eflu11-eflu14 eflu21-eflu24; /* date edit flag.; */ array sds (8) sdsu11-sdsu14 sdsu21-sdsu24; /* start date in SAS Date format. */ array sde (8) sdeu11-sdeu14 sdeu21-sdeu24; /* stop date in SAS Date format. */ array inc (8) incu11-incu14 incu21-incu24; /* daily amount. */ array dataprb (*) dataprb0-dataprb10; /* data problem flags */ /********************************************************************************************/ /* Initialize the CVC to latest CVC value. Initiate data problem flags & counters to zero. */ /* Create date of birth, DCI, DLI etc. in CMS scheme and SAS Date format. */ /********************************************************************************************/ do j=1 to dim(cvcuir); CUIR(j)=cvcuir(j); CUIA(j)=cvcuia(j); CUIS(j)=cvcuis(j); end; CUIEV = CVCUIEV_r18; CUIR2019=-4; CUIR2020=-4; CUIA2019=-4; CUIA2020=-4; CUIS2019=-4; CUIS2020=-4; /* Initiate flag & counter to zero. */ do i = 1 to dim(dataprb); dataprb(i)=0; end; handedit=0; /*******************************************************************************************/ /* Create date variables in 2 formats-SAS Date formate value, Continuous Month Scheme (CMS) when applicable - Date of Birth, Date of 14th birthday, DLI, day after DLI, month after DLI, DCI, day before DCI, month before DCI, day after DCI, month after DCI. SAS Date format is a Continuous Day Scheme(Jan.01, 1960 defined as day-0). The advantages of using SAS Date format/Continuous Day Scheme: 1. varied length of every month are automatically taken care of, use the actual number of days in the actual month, so the programmer doesn't have to worry about how many days in each continous month scheme, leap year problem etcetera. 2. it's convenient to calculate the length of unemployment spell durations to day- precision. The programmer doesn't have to manually add days (which depend on length of months). 3. It automatically place logic check on date values. For example, two Respondents in R12 reported Sept.31,2008 as their start/end date (which were accepted in survey program!). These will not pass through SAS Date format logic check. Also save the programmer's manual check on valid date patterns. Use SAS date format as the day-precision is best for day before/after variables: sb - Date of Birth in SAS Date format s14 - Date of 14th birthday in SAS Date format sdli - DLI in SAS Date format sddli - day before DLI in SAS Date format sdlid - day after DLI in SAS Date format sdci - DCI in SAS Date format sddci - day before DCI in SAS Date format sdcid - day after DCI in SAS Date format CMS is adopted in 97 survey with Jan, 1980 defined as month 1: cb - Date of Birth in CMS(continuous month scheme) c14 - Date of 14th birthday in CMS cdli - DLI in CMS cmdli - month before DLI in CMS cdlim - month after DLI in CMS cdci - DCI in CMS cmdci - month before DCI in CMS cdcim - month after DCI in CMS Check to make sure these time point variables exist for every R interviewed before running the rest of the program, since missing value in these time points might result in execution error. R13 checked these time points are good, no handedit is needed for this section either. */ /******************************************************************************************/ /* Birthdate variables, variables are valid for mdy() function*/ cb= (BDATEY-1980)*12+BDATEM; c14= (BDATEY-1980+14)*12+BDATEM; sb=mdy(BDATEM,BDATED,BDATEY); if BDATED<=day(intnx('month',mdy(BDATEM,1,(BDATEY+14)),0,'e')) then s14=mdy(BDATEM,BDATED,(BDATEY+14)); else s14=intnx('month',mdy(BDATEM,1,(BDATEY+14)),0,'e'); /*Date of Last Interview (DLI)*/ do i=1 to dim(intmR); if intmR(i)>-4 then dli_rnd=i; end; if 1<=dli_rnd<=dim(intmR) then do; if 1<=intmR(dli_rnd)<=12 & 1990<=intyR(dli_rnd)<=year(today()) then do; cdli=(intyR(dli_rnd)-1980)*12+intmR(dli_rnd); cmdli = cdli-1; cdlim = cdli+1; if 1<=intdR(dli_rnd)<=day(intnx('month',mdy(intmR(dli_rnd),1,intyR(dli_rnd)),0,'e')) then sdli = mdy(intmR(dli_rnd),intdR(dli_rnd),intyR(dli_rnd)); else do; sdli = intnx('month',mdy(intmR(dli_rnd),1,intyR(dli_rnd)),0,'e'); handedit=handedit+1; end; sddli = sdli-1; sdlid = sdli+1; end; else dataprb0=dataprb0+1; /* dataprb0 is a counter for invalid date. */ end; else dataprb0=dataprb0+1; /* Date of Current Interview (DCI): If day of DCI invalid, assign it to start of the month*/ if 1<=intm<=12 & 1990<=inty<=year(today()) then do; /* both month & year are good for CMS*/ cdci=(inty-1980)*12+intm; cmdci=cdci-1; cdcim=cdci+1; if 1<=intd<=day(intnx('month',mdy(intm,1,inty),0,'e')) then sdci=mdy(intm,intd,inty); else do; sdci=mdy(intm,1,inty); handedit=handedit+1; end; sddci = sdci-1; sdcid = sdci+1; end; else dataprb0=dataprb0+1; /********************************************************************************************* *Define the start date and end dates. If R reports still receiving, then use DCI as the * *temporary end date for the last loop. In the next survey round, R will be asked if s/he * *is still receiving. If not, then a permanent end date equivalent to the interview date * *of the last round will be assigned. If start or end dates are missing, impute those dates. * *Users will be able to tell what was imputed by looking at the following participation flag * *variable created during the program. The categories are the following: * * 1=R reported participation dates * * 2=start month imputed * * 3=start month and year imputed * * 4=stop month imputed * * 5=stop month and year imputed * * 6=start and stop dates imputed * * 7=err_or in data due to questionnaire problems or inconsistent response. * * Both results in our not sure whether Rs received in these months or not. * * QUESTIONNAIRE ERR_OR: These Rs reported valid start and stop dates but were never* * asked the follow-up question - if they received again. * * CONFLICTING RESPONSE: These Rs reported currently receiving, a valid start date * * and a valid stop date that is different from the DCI but in* * the follow-up question as to whether they received again, * * they answered NO. * *********************************************************************************************/ /******************************************************************************************/ /* Create start and stop dates of unemployment spells. Valid spell range: from "day after last spell end day" to "day before next spell start day". For the 1st loop, day after Last interview bounds like "day after last spell end day". For the last loop, date of current interview bounds like "day before next spell start day" Reported date outside valid range will be handedited and flagged dataprb**. Missing month & year will be imputed (when they are <0) and assigned efl flags accordingly. The assignment works in three steps, valid range is updated(narrowed) after each step : 1. month, year are reported, day or estimated day is reported: assign date, then align with valid range. 2.1 month not reported, but year reported: (imputation doesn't use day even if reported) if spell length reported & the other end of spell is known, calculate from the other end & length. Then align with valid range , which is also restricted by reported year. 2.2 year not reported: (imputation doesn't use month or day even if reported) if spell length reported & the other end of spell is known, calculate from the other end & length - then align with valid range (not restricted by reported month or day). 3. revise spells affected by Questionnaire Err_or or Inconsistency answers.*/ /******************************************************************************************/ /* Step 1. If day, month and year are all reported, assign SAS format date in valid range. If reported day is not within valid range, align to the closest day in valid range. Assumptions for estimated day: For start day, if R estimate beginning of the month, assign the 1st day of the month, middle of the month is assigned 11th day, while end of the month is assigned 21st day. If estimated day is unknown/missing, assume the start day to be the 1st of the month. For end day, if R estimate beginning of the month, assign the 9th day of month, middle of the month is assigned 19th day, while end of the month is assigned end of the month. If estimated day is unknown/missing, assume the start day to be end of the month. Estimated day flag=dataprb1: the integer indicates the loop & the decimal digit tells why: dataprb=p+.1: only estimated start day in (-3,-2,-1), set start day to 1st of the month dataprb=p+.2: only estimated stop day in (-3,-2,-1), set stop day to end of the month dataprb=p+.3: both estimated start/stop day in (-3,-2,-1), set start day=1st & stop=last*/ do p=1 to dim(sds); /* assign lower & upper bound for start day (slb, sub) the p~= condition makes sure p isn't first loops when sde(p-1) doesn't make sense. the max() assign the latest of bounds to slb. */ if p~=1 & p~=(dim(sds)/2+1) then slb= max(sde(p-1)+1, sdlid); else slb=sdlid; sub=sdci; if year(slb)<=ys(p)<=year(sub) & 1<=ms(p)<=12 then do; if 1<=ds(p) then sds(p)= mdy(ms(p),min(ds(p),day(intnx('month',mdy(ms(p),1,ys(p)),0,'e'))),ys(p)); else if es(p)=1 then sds(p)= mdy(ms(p),1,ys(p)); else if es(p)=2 then sds(p)= mdy(ms(p),11,ys(p)); else if es(p)=3 then sds(p)= mdy(ms(p),21,ys(p)); else if -4sub then sds(p)=sub; end; /* Set start date to day after DLI (sdlid) if receiving at DLI. if still receiving now set stop date to DCI, also set nogaps=1 */ if dli(p)=1 then do; sds(p)= sdlid; if stpgp(p)=0 & cwks(p)=1 then do; sde(p)=sdci; nogaps=1; end; end; /* Set end date to DCI if receiving now */ if cur(p)=1 & stpgp(p)=0 then sde(p)=sdci; /* assign lower & upper bound for end day (elb, eub), In step 1 first time assigning day values, sds(p+1) could not have any value in p-th loop. the max() in eub uses the latest of the dates as bound. */ elb=max(sds(p),sdlid); eub=sdci; /* Set end date if both end month and year are in valid range. End date is constrained by start date (if sde(p-1) exist then sds(p) already constrained) & day after DLI */ if year(elb)<=ye(p)<=year(eub) and 1<=me(p)<=12 then do; if 1<=de(p) then sde(p)= mdy(me(p),min(de(p),day(intnx('month',mdy(me(p),1,ye(p)),0,'e'))),ye(p)); else if ee(p)=1 then sde(p)=mdy(me(p),9,ye(p)); else if ee(p)=2 then sde(p)=mdy(me(p),19,ye(p)); else if ee(p)=3 then sde(p)=intnx('month',mdy(me(p),28,ye(p)),0,'e'); else if -4eub then sde(p)=eub; end; if slb<=sds(p)<=sde(p)<=eub then efl(p)=1; end; /* End of Step 1. */ /* Step 2. If month or year in (-3,-2,-1): if spell length reported & the other end of the spell is known, calculate from the other end & length. Align with valid range (also restricted by year if it's reported). corresponding to efl (2)-(6) cases */ do p=1 to dim(sds); /* (2) & (3) have good end date, bad start date */ if sdlid<=sde(p)<=sdci & (sdlid<=sds(p)<=sde(p) )=0 then do; /* assign lower & upper bound for start day (slb, sub) the p~= condition makes sure p isn't first loops when sde(p-1) doesn't make sense. the max() assign the latest of bounds to slb */ if p~=1 & p~=(dim(sds)/2+1) then slb= max(sde(p-1)+1, sdlid); else slb=sdlid; sub=sde(p); /* (2) if start year is reported and month is unknown but end date is good. Constrain valid range further by reported start year. New_lower_bound = max(Previous_lower_bound, Jan.1 of start year) New_upper_bound = min(Previous_upper_bound, Dec.31st of start year) Count backwards by the days of weeks if reported. Constrain start date by closest of the bounds */ if ys(p)>0 & -3<=ms(p)<=-1 then do; slb=max(slb,mdy(1,1,ys(p))); sub=min(sub,mdy(12,31,ys(p))); if wks(p)>=0 then do; flag21=1; sds(p)= sde(p)-(wks(p)*7); efl(p)=2.1; end; if sds(p)sub then do; flag21=0; sds(p)=sub; efl(p)=2; end; end; /* End of (2) */ /* (3) If start year is unknown but end date is good (valid range not affected by reported month). Count backwards by the days of weeks if reported. Constrain start date by closest of the bounds */ if -3<=ys(p)<=-1 then do; if wks(p)>=0 then do; flag22=1; sds(p)= sde(p)-(wks(p)*7); efl(p)=3.1; end; if sds(p)sub then do; flag22=0; sds(p)=sub; efl(p)=3; end; end; /* End of (3) */ end; /* End of (2) & (3)*/ /* (4) & (5) have good start date, bad end date */ else if sdlid<=sds(p)<=sdci & (sds(p)<=sde(p)<=sdci)=0 then do; /* assign lower & upper bound for end day (elb, eub), the p~= condition makes sure p isn't the last loop when sds(p+1) doesn't make sense. the max() in eub makes sure missing value in sds(p+1) wasn't mistaken as result of min()*/ elb= max(sds(p), sdlid); if p~= dim(sds)/2 & p~= dim(sds) & sdlid<=sds(p+1)<=sdci then eub= sds(p+1)-1; else if yprg_1930_upd=0 then eub=sdci-14; else eub=sdci; /* (4) If end year is reported and end month is reported, but start date is good. Constrain valid range further by reported end year. New_lower_bound = max(Previous_lower_bound, Jan.1 of end year) New_upper_bound = min(Previous_upper_bound, Dec.31st of end year) Count forward the days of reported weeks if reported. Constrain start date by closest of the bounds. */ if ye(p)>0 & -3<=me(p)<=-1 then do; elb= max(elb, mdy(1,1,ye(p))); eub= min(eub, mdy(12,31,ye(p))); if wks(p)>=0 then do; flag31=1; sde(p)=sds(p)+wks(p)*7; efl(p)=4.1; end; if sde(p)eub then do; flag31=0; sde(p)=eub; efl(p)=4; end; end; /* End of (4) */ /* (5) If stop year is unknown but start date is good (valid range not affected by reported month). Count backwards by the days of weeks if reported. Constrain start date by closest of the bounds*/ if -3<=ye(p)<=-1 then do; if wks(p)>=0 then do; flag32=1; sde(p)=sds(p)+wks(p)*7; efl(p)=5.1; end; if sde(p)eub then do; flag32=0; sde(p)=eub; efl(p)=5; end; end; /* End of (5) */ end; /* End of (4) & (5)*/ /* (6) If both the start and stop years are bad. if next spell start day is good, set end date to day before next spell start day, count backward weeks if known, constrain by last spell stop day; if last spell stop day is good, set start date to day after last spell stop day, count forward weeks if known, constrain by next spell start day. */ else if ( sdlid<=sds(p)<=sdci )=0 & (sdlid<=sde(p)<=sdci)=0 & ys(p) not in (.,-5,-4) & ye(p) not in (.,-5,-4) then do; if p~=1 & p~=(dim(sds)/2+1) then slb= max(sde(p-1)+1, sdlid); else slb=sdlid; if yprg_1930_upd=0 then sub=sdci-14; else sub=sdci; if ys(p)>0 & -3<=ms(p)<=-1 then do; slb=max(slb,mdy(1,1,ys(p))); sub=min(sub,mdy(12,31,ys(p))); end; elb=sdlid; if p~= dim(sds)/2 & p~= dim(sds) & sdlid0 & -3<=me(p)<=-1 then do; elb= max(elb, mdy(1,1,ye(p))); eub= min(eub, mdy(12,31,ye(p))); end; sde(p)= eub; if wks(p)>=0 then sds(p)=sde(p)-wks(p)*7; if sds(p)sub then sds(p)=sub; efl(p)=6; end; /* End of (6) */ end; /* End of Step 2.(2)-(6) imputation. */ /* Step 3. Questionnaire Err_or or Inconsistency answers. QUESTIONNAIRE ERR_OR: Questionnair routing goes different than 'should be' route. For example, R reported valid start and stop dates but was never asked the follow-up question - if they received again. CONFLICTING RESPONSE: For example, R reported currently receiving, a valid start date and a valid stop date that is different from the DCI but in the follow-up question as to whether they received again, they answered NO. mostly corresponding to efl (7) cases, other efl flags are possible */ do p=1 to dim(sds); /* R reports receiving, but doesn't know whether stopped for more than a month and so no information on stop date. We then impute the stop date to DCI and put efl=5 */ if -3<=stpgp(p)<=-1 & (sdlid<=sde(p)<=sdci)=0 then do; dataprb2=p; sde(p)=sdci; if yprg_1930_upd=0 then do; sde(p)=max( sdci-14, sds(p)); flag1=1; end; efl(p)=5; handedit=handedit+1; end; /* End of HandEdit dataprb2 */ /* Rs report currently not receiving but no periods of 2 weeks+ didn't recieve, and end day is missing as a result. We take them to be receiving 2 weeks before the DCI. and bound by spell start date. */ if (cur(p)=0 or cwks(p)=0) & stpgp(p)=0 then do; dataprb3=p; if sdlid<=sds(p)<=sdci & (sdlid<=sde(p)<=sdci)=0 then do; sde(p)=max( sdci-14, sds(p)); efl(p)=7; handedit=handedit+1; end; end; /* End of HandEdit dataprb3 */ /* Rs report currently receiving, at least 2 weeks when they didn't receive, have a valid stop date but said NO they didn't received again, so the next loop is invalid. Create another loop from the day after the reported stop to DCI, and put efl=7 & inc=-3. IF THE STOP DATE IS SDCI, THEN WE DO NOT HANDEDIT*/ if (cur(p)=1 or cwks(p)=1) & stpgp(p)=1 & sdlid<=sde(p)0 but UIAMT is missing */ uicka=0; /* Counter=1 when UIAMT is not missing (>=-3) but UIREC=0 */ uickv=0; /* Counter=1 when UIREC is invalid but UIAMT not invalid */ uiodttl=0; /* Counter for total number of months received the problematic amounts */ /* Create csm() cem(), uirec uiamt, check results. */ do p=1 to dim(sds); /* [B2] */ /* Change weekly amount to daily amount, use both reported & estimated variables. */ if incm(p)>=0 then inc(p)=incm(p)/7; else if -3<=incm(p)<=-1 then do; if eincm(p)=1 then inc(p)=(50/7); else if eincm(p)=2 then inc(p)=(125/7); else if eincm(p)=3 then inc(p)=(175/7); else if eincm(p)=4 then inc(p)=(225/7); else if eincm(p)=5 then inc(p)=(300/7); else if eincm(p)=6 then inc(p)=(351/7); else if -3<=eincm(p)<=-1 then inc(p) = -3; end; if sdlid<=sds(p)<=sde(p)<=sdci then do; /*[B2-1] only valid start & end dates enters*/ csm(p)=(year(sds(p))-1980)*12+month(sds(p)); cem(p)=(year(sde(p))-1980)*12+month(sde(p)); /* First Step. Assign uiamt, uirec (starting from DLI month) */ do d= sds(p) to sde(p); m= (year(d)-1980)*12+month(d); /*Continous Month(m) for Continuous Day(d)*/ if UIAMT(m)>=0 then do; /*don't update uiamt(m) if uiamt(m) is <0*/ if inc(p)>=0 then UIAMT(m) = UIAMT(m) + inc(p); /*Add daily amount to uiamt(m)*/ else if -3<=inc(p)<=-1 then UIAMT(m) = inc(p); /*? income=? monthly amount*/ end; if UIREC(m)=0 & efl(p)>=1 then UIREC(m)=efl(p); /*uirec is updated. if 2 loops span this month, use efl of the first loop */ if UIREC(m) in (2.1 3.1 4.1 5.1) then UIREC(m)=1; if UIREC(m) ne 1 then do; if (ys(p)-1980+1)*120 then UIREC(m)=1; else if (ys(p)-1980)*12+ms(p)<=m<=(ys(p)-1980+1)*12 & ys(p)>0 & ms(p)>0 & ye(p)>ys(p) then UIREC(m)=1; else if (ye(p)-1980)*120 & me(p)>0 & ye(p)>ys(p) then do; UIREC(m)=1; typo1=1;end; end; end; /* End of First Assign Step */ /* 'Move CDLI to CDLIM': if spell start day is in DLI(cdli), move uiamt(cdli) uirec(cdli) to month after DLI (cdlim). But don't change csm(p) to cdlim. */ if (year(sds(p))-1980)*12+month(sds(p))=cdli then do; /* Only uiamt(cdlim)>=0 will be updated by uiamt(cdli) don't change if uiamt(cdlim)<0 already. */ if uiamt(cdlim)>=0 then do; if uiamt(cdli)>=0 then uiamt(cdlim)=uiamt(cdlim)+uiamt(cdli); else if -3<=uiamt(cdli)<=-1 then uiamt(cdlim)=-3; end; /* Only uirec(cdlim)=0 will be updated by uiamt(cdli), don't change if uirec(cdlim)>=1 already. */ if uirec(cdlim)=0 & uirec(cdli)>=1 then uirec(cdlim)=uirec(cdli); handedit=handedit+1; dataprb7=p; end; /* End of 'Move CDLI to CDLIM' */ /* check uiamt for too high amount, or disagreement between uirec uiamt. */ do m= (year(sds(p))-1980)*12+month(sds(p)) to m= (year(sde(p))-1980)*12+month(sde(p)); if UIAMT(m)>10000 then uiodttl=uiodttl+1; if UIREC(m)>0 & UIAMT(m)=. then uickr=uickr+1; else if UIREC(m)=0 & -3<=UIAMT(m) then uicka=uicka+1; else if UIREC(m)=-3 and UIAMT(m)~=-3 then uickv=uickv+1; end; /* End of Check Flags */ end; /* [E2-1] */ end; /* [E2] */ /*delete uiamt(cdli) uirec(cdli) for all Rs including Rs who did not go through this section as the CDLI event history variabels exist from the last round and we don't need to re-create them during this round. */ uiamt(cdli)=.; uirec(cdli)=.; /* Divide the problematic amount by the # of months receiving the problematic amounts. Note the loop only needs to run from cdlim to cdci - we don't allow amt earlier than CDLI or later than DCI */ if uiodttl>0 then do m=cdlim to cdci; if UIAMT(m)>10000 & UIREC(m)>0 then UIAMT(m)=round(UIAMT(m)/uiodttl); end; /* Check cases if months before DLI or after DCI is not missing (.) */ do m= 1 to dim(UIREC) while (dataprb8=0); if (m<= cmdli | m>=cdcim ) & ( UIREC(m)~=. | UIAMT(m)~=. ) then dataprb8=m; end; /********************************************************************************************* *Update the CVC variables - months receiving in each year (CUIRx), the amount receiving each * *year (CUIAx), the number of UNEMP spells started each year (CUISx) and the total # of months* *received ever (CUIEV) - as reported in this round. * *********************************************************************************************/ do j=1 to dim(CUIR); if CUIR(j)=-4 then do m=((j*12)-11) to (j*12); if UIREC(m)=0 then do; CUIR(j)=0; datacheck=1; end; end; end; do j=1 to dim(CUIR); if (-3<=CUIR(j)<=-1)=0 then do m=((j*12)-11) to (j*12); if UIREC(m)=1 then do; if CUIR(j)>=0 then CUIR(j)=CUIR(j)+1; else if CUIR(j)=-4 then CUIR(j)=1; end; else if UIREC(m)>1 | -3<=UIREC(m)<=-1 then CUIR(j)=-3; if (-3<=CUIA(j)<=-1)=0 then do; if UIAMT(m)>=0 then do; if CUIA(j)>=0 then CUIA(j)=CUIA(j)+UIAMT(m); else if CUIA(j)=-4 then CUIA(j)=UIAMT(m); end; else if -3<=UIAMT(m)<=-1 then CUIA(j)=-3; end; end; if -3<=CUIR(j)<=-1 then CUIA(j)=-3; else if CUIR(j) in (0,-4) then CUIA(j)=-4; if CUIA(j)>0 then CUIA(j)=round(CUIA(j)); /* End of Update & Align of UIREC UIAMT*/ if CUIR(j)>=13 then dataprb9=j; /* Update Spells CUISx. Notice start & stop date already limited to no earlier than DLI & no later than DCI.*/ do p=1 to dim(sds); if sdlid<=sds(p)<=sde(p)<=sdci & ( dli(p)~=1 | YPRG_1899_UPD=1 ) & -11<=(year(sds(p))-1980-j)*12+month(sds(p))<=0 then do; if CUIS(j)>=0 then CUIS(j)=CUIS(j)+1; else if CUIS(j)=-4 then CUIS(j)=1; end; end; if (CUIA(j) not in (.,-4,0) | CUIR(j) not in (.,-4,0) ) & CUIS(j)=-4 then CUIS(j)=0; if CUIA(j) in (.,-4,0) & CUIR(j) in (.,-4,0) & CUIS(j)=0 then CUIS(j)=-4; /* End of Update & Align of CUISx */ end; /* Update CUIEV. Don't update if -3<=CUIEV<=-1 already. Notice loop run from cdlim to CDCI since we limited month variable to that range. */ if (-3<=CUIEV<=-1)=0 then do m=cdlim to cdci; if UIREC(m)=1 then do; if CUIEV>=0 then CUIEV=CUIEV+1; else if CUIEV=-4 then CUIEV=1; end; else if UIREC(m)>1 or UIREC(m) in (-1,-2,-3) then CUIEV=-3; end; /* Change (-3,-2,-1) to -3 */ array skip3 CUIEV CUIR: CUIA: CUIS: UIAMT: UIREC:; do over skip3; if skip3 in (-1,-2) then skip3=-3; end; /* Check for disagreement between CVC variables.(dataprb10).*/ do j=1 to dim(CUIA) while (dataprb10=0); if CUIR(j) in (-4,0) & CUIA(j) not in (.,-4) then dataprb10=j+0.1; else if CUIR(j)=-3 & CUIA(j)~=-3 then dataprb10=j+0.2; else if 1<=CUIR(j)<=12 & CUIA(j) in (.,-4) then dataprb10=j+0.3; if ( CUIR(j)=-3 | CUIR(j)>=1 ) & CUIS(j)=-4 then dataprb10=max(j,dataprb10)+0.01; if CUIR(j) in (0,-4) & CUIS(j) ne -4 then dataprb10=max(j,dataprb10)+0.02; if CUIS(j)>=1 & CUIA(j)=-4 then dataprb10=max(j,dataprb10)+0.001; if CUIR(j)>-4 & CUIEV in (., -4) then dataprb10=max(j,dataprb10)+0.0001; else if -40 then do; _tempsum = _tempsum+CUIR(j); if _tempsum>CUIEV>0 then dataprb10=max(j,dataprb10)+0.0003; end; end; if dataprb10=0 & _tempsum>=0 & CUIEV>=0 & _tempsum~=CUIEV then dataprb10=0.0004; if YPRG_1930_UPD>-4 then get=1; if get=. then get=0; /******************************************************************************************* *Variables created: UIREC001-UIREC487 * * UIAMT001-UIAMT487 * * csmu11-csmu14 * * cemu11-cemu14 * * eflu11-eflu14 * * * * * * Created Variable names on CD Created Variable names in this program * * UNEMP_STATUS_XXXX.XX UIREC001-UIREC487 * * UNEMP_AMT_XXXX.XX UIAMT001-UIAMT487 * * UNEMP_START_MONTH_XXXX.0X csmu11-csmu14 * * UNEMP_STOP_MONTH_XXXX.0X cemu11-cemu14 * * UNEMP_EDIT_DATE_XXXX.0X eflu11-eflu14 * * * *******************************************************************************************/ data event; set one; *event history arrays: csm, cem, efl, UIREC, UIAMT; array UIREC UIREC001-UIREC492; *indicator for receipt, monthly. ; array UIAMT UIAMT001-UIAMT492; *amount received, monthly. ; array csm (8) csmu11-csmu14 csmu21-csmu24; *start date in CMS. ; array cem (8) cemu11-cemu14 cemu21-cemu24; *stop date in CMS. ; array efl (8) eflu11-eflu14 eflu21-eflu24; *date edit flag. ; array inc (8) incu11-incu14 incu21-incu24; *daily amount. ; do p=1 to dim(efl); if efl(p)=2.1 then efl(p)=2; if efl(p)=3.1 then efl(p)=3; if efl(p)=4.1 then efl(p)=4; if efl(p)=5.1 then efl(p)=5; end; *Convert all monthly variables to create the event history variables; do m=1 to dim(uirec); if uirec(m)>1 then uirec(m)=1; else if uirec(m)=. then uirec(m)=-4; if uiamt(m)>0 then uiamt(m)=round(uiamt(m)); else if uiamt(m)=. then uiamt(m)=-4; if uirec(m)=0 then do; uiamt(m)=-4; checkthis=1; end; end; *Spells from 'Since-DLI' section and 'Never-Prior' section are combined; nvpr=0; do k=1 to 4; if csm(4+k)~=. | cem(4+k)~=. then nvpr=k; end; dataprb13=0; if nvpr>=1 then do k=1 to 4 while(dataprb13=0); if csm(k)~=. | cem(k)~=. | inc(k)~=. |efl(k)~=. then dataprb13=k; end; if nvpr~=0 & dataprb13=0 then do p = 1 to nvpr; csm(p)=csm(p+4); cem(p)=cem(p+4); efl(p)=efl(p+4); end; *****make sure all missing value to be -4; array CV CUIEV CUIR1997-CUIR2020 CUIA1997-CUIA2020 CUIS1997-CUIS2020 csmu11-csmu14 cemu11-cemu14 eflu11-eflu14 UIAMT205-UIAMT492 UIREC205-UIREC492; do over CV; if cv=. then cv=-4; end;