/************************************************************************** Program: LGT Multivariate Setup.sas Project: Housing Discrimination Study - LGT Author: Rob Pitingolo Created: 8-21-15 Edited: 10/29/2015 by Sarale Sewell Description: Creates data file for multivariate analysis. **************************************************************************/ ** Libraries **; libname lgt 'Y:\METRO\HDS-LGT\raw\SAS\201521Sept'; libname tid 'Y:\METRO\HDS-LGT\raw\Identifiability results'; libname i 'Y:\METRO\HDS-LGT'; ** Analysis as of the current date **; %let date = &sysdate. ; ** List of sitecodes **; %let sitecodes = DC DL LA; ** SAS options **; options mprint ; ** Code control and LGT testers **; %macro ttyp; if 10 <= classid <=19 then ttyp = 2; /* Protected */ else if 20 <= classid <=29 then ttyp = 1; /* Control */ %mend ttyp; /* Macro to make site dummies */ %macro sitedummy(); %let varlist = &sitecodes.; %let i = 1; %do %until (%scan(&varlist,&i," ")=); %let var=%scan(&varlist,&i," "); if site = "&var." then &var._DUMMY = 1; else &var._DUMMY = 0; %let i=%eval(&i + 1); %end; %let i = 1; %do %until (%scan(&varlist,&i," ")=); %let var=%scan(&varlist,&i," "); %let i=%eval(&i + 1); %end; %mend sitedummy; /* Macro to switch -1 to missing */ %macro makemissing(varlist); %let varlist = &varlist.; %let i = 1; %do %until (%scan(&varlist,&i," ")=); %let var=%scan(&varlist,&i," "); if &var. = -1 then &var. = . ; %let i=%eval(&i + 1); %end; %let i = 1; %do %until (%scan(&varlist,&i," ")=); %let var=%scan(&varlist,&i," "); %let i=%eval(&i + 1); %end; %mend makemissing; /* Macro to fix half values */ %macro half(varlist); %let varlist = &varlist.; %let i = 1; %do %until (%scan(&varlist,&i," ")=); %let var=%scan(&varlist,&i," "); if &var. > 1.05 then &var. = &var./2; %let i=%eval(&i + 1); %end; %let i = 1; %do %until (%scan(&varlist,&i," ")=); %let var=%scan(&varlist,&i," "); %let i=%eval(&i + 1); %end; %mend half; /* Load appointment form for approved tests*/ proc sql noprint; CREATE TABLE appt_in AS SELECT * FROM lgt.Apptcall WHERE control IN (SELECT control FROM lgt.taf WHERE fpass = 1 ) ORDER BY control ; quit; /* Load appointment outcomes */ data appt; set appt_in; %ttyp; if ccallc in (2,3) then apptyes = 1; if ccallc in (1) then apptyes = 0; if ttyp = 1 and apptyes = 1 then c_appt = 1; else if ttyp = 1 and apptyes = 0 then c_appt = 0; if ttyp = 2 and apptyes = 1 then lg_appt = 1; else if ttyp = 2 and apptyes = 0 then lg_appt = 0; run; proc summary data = appt; class control; var c_appt lg_appt; output out = appt_sum sum=; run; data appt_fin; set appt_sum; if c_appt >0 and lg_appt >0 then appt_both = 1; else appt_both = 0; if c_appt >0 and lg_appt in (0,.) then appt_onlyc = 1; else appt_onlyc = 0; if c_appt in (0,.) and lg_appt >0 then appt_onlylg = 1; else appt_onlylg = 0; if c_appt in (0,.) and lg_appt in (0,.) then appt_neither = 1; else appt_neither = 0; keep control c_appt lg_appt appt_both appt_onlyc appt_onlylg appt_neither; run; proc sort data = appt_fin; by control; run; /** Read in the tester application and calculate age from DOB **/ data tester; set lgt.tester; /** D. D'Orio - calculate age **/ /** define length of string so it doesn't chop off the end ***/; length date_string $25; /** these formats all work. Just rearrange the order so that the string you want to test is assigned last ****/ date_string=tdob; /*** check for hyphenated string ***/; isHyphen=0; isHyphen=index ( date_string, "-" ); /** no hyphen present **/ if isHyphen <1 then do; month= scan( date_string, 1, "/" ); day = scan( date_string, 2, "/" ); year= scan( date_string, 3, "/" ); end; /** hyphen present **/ else do; month= scan( date_string, 1, "-" ); day = scan( date_string, 2, "-" ); year= scan( date_string, 3, "-" ); end; /** create date of borth from parts ***/; dob = MDY(input(month,best12.), input(day,best12.), input(year,best12.)); /** create age to date /****/ age = intck("year",dob,today()); if age < 10 then age = TAGE; drop /*date_string isHyphen*/ month day year dob TAGE; if TNATORIG = 2 then arace = 3; else if aprace = 1 then arace = 1; else if aprace = 2 then arace = 2; else if aprace = 4 then arace = 4; else arace = 5; TRACE = arace; drop arace; /** Creat dummy variables for sex, gender ID, and orientation **/ if tsex = 0 then BIRTHFEMALE = 1; else BIRTHFEMALE = 0; if tsex = 1 then BIRTHMALE = 1; else BIRTHMALE = 0; if genderID = 1 then CISMALE = 1; else CISMALE = 0 ; if genderID = 2 then CISFEMALE = 1; else CISFEMALE = 0 ; if genderID = 3 then TRANSMALE = 1; else TRANSMALE = 0 ; if genderID = 4 then TRANSFEMALE = 1; else TRANSFEMALE = 0 ; if genderID in (5,6) then GENDEROTH = 1; else GENDEROTH = 0 ; if sexorient = 1 then STRAIGHT = 1; else STRAIGHT = 0; if sexorient = 2 then GAY = 1; else GAY = 0; if sexorient = 3 then LESBIAN = 1; else LESBIAN = 0; if sexorient = 4 then BISEX = 1; else BISEX = 0; if sexorient = 5 then ORIENTOTH = 1; else ORIENTOTH = 0; run; proc sort data = tester; by testerid; run; /* Load rental form for approved tests*/ proc sql noprint; CREATE TABLE rental_in AS SELECT * FROM lgt.rental WHERE control IN (SELECT control FROM lgt.taf WHERE fpass = 1) ORDER BY control ; quit; /* Load in-person available unit form for approved tests */ proc sql noprint; CREATE TABLE availunit_in AS SELECT * FROM lgt.availunit WHERE (DELREC = 0 or DELREC = .) AND control IN (SELECT control FROM lgt.taf WHERE fpass = 1) ORDER BY control ; quit; /* Load remote available unit form for approved tests */ proc sql noprint; CREATE TABLE availunitt_in AS SELECT * FROM lgt.availunitt WHERE (DELREC = 0 or DELREC = .) AND control IN (SELECT control FROM lgt.taf WHERE fpass = 1) ORDER BY control ; quit; /* Combine site visit data with assignment data for those tests */ proc sql; CREATE TABLE rental_seq AS SELECT a. *, b.sequence,aincmont,phhcomp,pbeds FROM rental_in as a, lgt.assignment as b WHERE a.control=b.control and a.testerid=b.testerid ORDER BY control, testerid; quit; /** Load race and gender identifiability information **/ %include "Y:\METRO\HDS-LGT\programs\raceidentifiability.sas"; %include "y:\METRO\HDS-LGT\programs\tidentifiability.sas"; proc sort data = rental_seq; by testerid; run; proc sort data = tester; by testerid; run; /* Combine data with identifiability data */ data rental_tid; merge rental_seq (in=a) tester lgt_out.race_ip_identifiability lgttech.transid_in ; by testerid; if a; run; proc sort data = rental_tid; by control testerid; run; /** Create variables and the tester-level **/ data multi_tl_lgt; merge rental_tid (in=a) /*sec.Hdsw_sec*/; by control testerid; if a; /** Recode race variables **/ ; %ttyp; /** Test type **/ if testtype in (1,2,5) then LESBIANTEST = 0.5; else LESBIANTEST = 0; if testtype in (3,4,6) then GAYTEST = 0.5; else GAYTEST = 0; if testtype in (7,8) then TRANSTEST = 0.5; else TRANSTEST = 0; /** Remote or IP **/ if testtype in (5,6) then REMOTE = 0.5; else REMOTE = 0; /** Convey **/ if testtype in (7) then CONVEY = 0.5; else if testtype in (8) then CONVEY = 0; /** Number of bedrooms **/ BROOMS = PBEDS / 2; if BROOMS > 20 then BROOMS = .; /** Tester birth sex **/ if ttyp in (1) then CBIRTHMALE = BIRTHMALE; if ttyp in (2) then LGBIRTHMALE = BIRTHMALE; if ttyp in (1) then CBIRTHFEMALE = BIRTHFEMALE; if ttyp in (2) then LGBIRTHFEMALE = BIRTHFEMALE; /** Tester gender **/ if ttyp in (1) then CCISMALE = CISMALE; if ttyp in (2) then LGCISMALE = CISMALE; if ttyp in (1) then CCISFEMALE = CISFEMALE; if ttyp in (2) then LGCISFEMALE = CISFEMALE; if ttyp in (1) then CTRANSMALE = TRANSMALE; if ttyp in (2) then LGTRANSMALE = TRANSMALE; if ttyp in (1) then CTRANSFEMALE = TRANSFEMALE; if ttyp in (2) then LGTRANSFEMALE = TRANSFEMALE; if ttyp in (1) then CGENDEROTH = GENDEROTH; if ttyp in (2) then LGGENDEROTH = GENDEROTH; /** Tester orientation **/ if ttyp in (1) then CSTRAIGHT = STRAIGHT; if ttyp in (2) then LGSTRAIGHT = STRAIGHT; if ttyp in (1) then CGAY = GAY ; if ttyp in (2) then LGGAY = GAY ; if ttyp in (1) then CLESBIAN = LESBIAN; if ttyp in (2) then LGLESBIAN = LESBIAN; if ttyp in (1) then CBISEX = BISEX; if ttyp in (2) then LGBISEX = BISEX; if ttyp in (1) then CORIENTOTH = ORIENTOTH; if ttyp in (2) then LGORIENTOTH = ORIENTOTH; /** Tester age **/ if ttyp in (1) then CAGE = age; if ttyp in (2) then LGAGE = age; /** Who went first **/ if ttyp in (1) and sequence = 1 then CFIRST = 1; else CFIRST = 0; if ttyp in (2) and sequence = 1 then LGFIRST = 1; else LGFIRST = 0; /** Did test happen in afternoon **/ ampm = substr(RBGNH,7,2); if ttyp in (1) and ampm = "PM" then CAFTERNOON = 1; else CAFTERNOON = 0; if ttyp in (2) and ampm = "PM" then LGAFTERNOON = 1; else LGAFTERNOON = 0; /** Tester currently employed **/ if ttyp in (1) and tcuremp = 1 then CCUREMP = 1; else CCUREMP = 0; if ttyp in (2) and tcuremp = 1 then LGCUREMP = 1; else LGCUREMP = 0; /** Tester currently homeowner **/ if ttyp in (1) and tcurtenr = 2 then CCURTENR = 1; else CCURTENR = 0; if ttyp in (2) and tcurtenr = 2 then LGCURTENR = 1; else LGCURTENR = 0; /** Tester has testing experience **/ if ttyp in (1) and texpernc = 1 then CEXPERNC = 1; else CEXPERNC = 0; if ttyp in (2) and texpernc = 1 then LGEXPERNC = 1; else LGEXPERNC = 0; /** Level of education **/ if ttyp in (1) then CHIGHEDU = thighedu ; if ttyp in (2) then LGHIGHEDU = thighedu; /** Tester looking for housing **/ if ttyp in (1) and thomehnt = 1 then CHOMEHNT = 1; else CHOMEHNT = 0; if ttyp in (2) and thomehnt = 1 then LGHOMEHNT = 1; else LGHOMEHNT = 0; /** Tester lives in MSA **/ if ttyp in (1) and tmalive = 1 then CMALIVE = 1; else CMALIVE = 0; if ttyp in (2) and tmalive = 1 then LGMALIVE = 1; else LGMALIVE = 0; /** Tester's gross income **/ if ttyp in (1) then CPEGAI = tpegai; if ttyp in (2) then LGPEGAI = tpegai; /** Tester was born in USA **/ if ttyp in (1) and tcorgin = 1 then CNBUS = 1; else CNBUS = 0; if ttyp in (2) and tcorgin = 1 then LGNBUS = 1; else LGNBUS = 0; /** Month of test **/ length date_string $25; date_string = rvdate; isHyphen=0; isHyphen=index ( date_string, "-" ); if isHyphen <1 then do; month= scan( date_string, 1, "/" ); end; /** hyphen present **/ else do; month= scan( date_string, 1, "-" ); end; nummonth = month + 0; if sequence = 1 then testmonth = nummonth; drop date_string isHyphen month nummonth; /** Control Tester assigned family with child **/ if ttyp in (1) and phhcomp in (4,5,6,7) then CCHILD = 1; else CCHILD = 0; if ttyp in (2) and phhcomp in (4,5,6,7) then LGCHILD = 1; else LGCHILD = 0; /** Control Tester is married **/ if ttyp in (1) and phhcomp in (3,4,5,6,7) then CMARRIED = 1; else CMARRIED = 0; if ttyp in (2) and phhcomp in (3,4,5,6,7) then LGMARRIED = 1; else LGMARRIED = 0; /** Control Tester is female **/ if ttyp in (1) and tsex = 0 then CAUDFEM = 1; else CAUDFEM = 0; if ttyp in (2) and tsex = 0 then LGAUDFEM = 1; else LGAUDFEM = 0; /** Control assigned income **/ if ttyp in (1) then CINCOME = aincmont ; if ttyp in (2) then LGINCOME = aincmont ; /** Whether primary interviewer was black, Hispanic, female, age, and gay **/ if ragmet1 = 1 then do; MAINAGT = 1; if ttyp in (1) then CPARACE = ragrace1; if ttyp in (2) then LGPARACE = ragrace1; if ttyp in (1) then CPASEX = raggend1; if ttyp in (2) then LGPASEX = raggend1; if ttyp in (1) then CPAAGE = ragage1; if ttyp in (2) then LGPAAGE = ragage1; if ttyp in (1) then CPANAME = ragname1; if ttyp in (2) then LGPANAME = ragname1; if ttyp in (1) and raggend1 = 2 then CAGFEM = 1; else CAGFEM = 0; if ttyp in (2) and raggend1 = 2 then LGAGFEM = 1; else LGAGFEM = 0; if ttyp in (1) then CAGAGE = ragage1; if ttyp in (2) then LGAGAGE = ragage1; if ttyp in (1) then CNAME = ragname1; if ttyp in (2) then LGNAME = ragname1; if ttyp in (1) and ragpso1 = 1 then CAGTGAY = 1; else CAGTGAY = 0; if ttyp in (2) and ragpso1 = 1 then LGAGTGAY = 1; else LGAGTGAY = 0; end; else if ragmet2 = 1 then do; MAINAGT = 1; if ttyp in (1) then CPARACE = ragrace2; if ttyp in (2) then LGPARACE = ragrace2; if ttyp in (1) then CPASEX = raggend2; if ttyp in (2) then LGPASEX = raggend2; if ttyp in (1) then CPAAGE = ragage2; if ttyp in (2) then LGPAAGE = ragage2; if ttyp in (1) then CPANAME = ragname2; if ttyp in (2) then LGPANAME = ragname2; if ttyp in (1) and raggend2 = 2 then CAGFEM = 1; else CAGFEM = 0; if ttyp in (2) and raggend2 = 2 then LGAGFEM = 1; else LGAGFEM = 0; if ttyp in (1) then CAGAGE = ragage2; if ttyp in (2) then LGAGAGE = ragage2; if ttyp in (1) then CNAME = ragname2; if ttyp in (2) then LGNAME = ragname2; if ttyp in (1) and ragpso2 = 1 then CAGTGAY = 1; else CAGTGAY = 0; if ttyp in (2) and ragpso2 = 1 then LGAGTGAY = 1; else LGAGTGAY = 0; end; else if ragmet3 = 1 then do; MAINAGT = 1; if ttyp in (1) then CPARACE = ragrace3; if ttyp in (2) then LGPARACE = ragrace3; if ttyp in (1) then CPASEX = raggend3; if ttyp in (2) then LGPASEX = raggend3; if ttyp in (1) then CPAAGE = ragage3; if ttyp in (2) then LGPAAGE = ragage3; if ttyp in (1) then CPANAME = ragname3; if ttyp in (2) then LGPANAME = ragname3; if ttyp in (1) and raggend3 = 2 then CAGFEM = 1; else CAGFEM = 0; if ttyp in (2) and raggend3 = 2 then LGAGFEM = 1; else LGAGFEM = 0; if ttyp in (1) then CAGAGE = ragage3; if ttyp in (2) then LGAGAGE = ragage3; if ttyp in (1) then CNAME = ragname3; if ttyp in (2) then LGNAME = ragname3; if ttyp in (1) and ragpso3 = 1 then CAGTGAY = 1; else CAGTGAY = 0; if ttyp in (2) and ragpso3 = 1 then LGAGTGAY = 1; else LGAGTGAY = 0; end; else if ragmet4 = 1 then do; MAINAGT = 1; if ttyp in (1) then CPARACE = ragrace4; if ttyp in (2) then LGPARACE = ragrace4; if ttyp in (1) then CPASEX = raggend4; if ttyp in (2) then LGPASEX = raggend4; if ttyp in (1) then CPAAGE = ragage4; if ttyp in (2) then LGPAAGE = ragage4; if ttyp in (1) then CPANAME = ragname4; if ttyp in (2) then LGPANAME = ragname4; if ttyp in (1) and raggend4 = 2 then CAGFEM = 1; else CAGFEM = 0; if ttyp in (2) and raggend4 = 2 then LGAGFEM = 1; else LGAGFEM = 0; if ttyp in (1) then CAGAGE = ragage4; if ttyp in (2) then LGAGAGE = ragage4; if ttyp in (1) then CNAME = ragname4; if ttyp in (2) then LGNAME = ragname4; if ttyp in (1) and ragpso4 = 1 then CAGTGAY = 1; else CAGTGAY = 0; if ttyp in (2) and ragpso4 = 1 then LGAGTGAY = 1; else LGAGTGAY = 0; end; else if ragmet5 = 1 then do; MAINAGT = 1; if ttyp in (1) then CPARACE = ragrace5; if ttyp in (2) then LGPARACE = ragrace5; if ttyp in (1) then CPASEX = raggend5; if ttyp in (2) then LGPASEX = raggend5; if ttyp in (1) then CPAAGE = ragage5; if ttyp in (2) then LGPAAGE = ragage5; if ttyp in (1) then CPANAME = ragname5; if ttyp in (2) then LGPANAME = ragname5; if ttyp in (1) and raggend5 = 2 then CAGFEM = 1; else CAGFEM = 0; if ttyp in (2) and raggend5 = 2 then LGAGFEM = 1; else LGAGFEM = 0; if ttyp in (1) then CAGAGE = ragage5; if ttyp in (2) then LGAGAGE = ragage5; if ttyp in (1) then CNAME = ragname5; if ttyp in (2) then LGNAME = ragname5; if ttyp in (1) and ragpso5 = 1 then CAGTGAY = 1; else CAGTGAY = 0; if ttyp in (2) and ragpso5 = 1 then LGAGTGAY = 1; else LGAGTGAY = 0; end; /** Fill in cases if tester didn't ID main agent **/ if ttyp in (1) then do; if CPARACE = . then CPARACE = ragrace1; if CPASEX = . then CPASEX = raggend1; if CPAAGE = . then CPAAGE = ragage1; if CPANAME = " " then CPANAME = ragname1; if CAGFEM = . and raggend1 = 0 then CAGFEM = 1; else if CAGFEM = . and raggend1 = 0 then CAGFEM = 0; if CAGAGE = . then CAGAGE = ragage1; if CNAME = " " then CNAME = ragname1; if CAGTGAY = . and ragpso1 = 0 then CAGTGAY = 1; else if CAGTGAY = . and ragpso1 = 0 then CAGTGAY = 0; end; if ttyp in (2) then do; if LGPARACE = . then LGPARACE = ragrace1; if LGPASEX = . then LGPASEX = raggend1; if LGPAAGE = . then LGPAAGE = ragage1; if LGPANAME = " " then LGPANAME = ragname1; if LGAGFEM = . and raggend1 = 0 then LGAGFEM = 1; else if LGAGFEM = . and raggend1 = 0 then LGAGFEM = 0; if LGAGAGE = . then LGAGAGE = ragage1; if LGNAME = " " then LGNAME = ragname1; if LGAGTGAY = . and ragpso1 = 0 then LGAGTGAY = 1; else if LGAGTGAY = . and ragpso1 = 0 then LGAGTGAY = 0; end; /** Agent Race Dummies **/ if CPARACE in (-1,.) then CAGBLK = . ; else if CPARACE = 2 then CAGBLK = 1; else if CPARACE in (1,3,4,7,8,9) then CAGBLK = 0; if LGPARACE in (-1,.) then LGAGBLK = . ; else if LGPARACE = 2 then LGAGBLK = 1; else if LGPARACE in (1,3,4,7,8,9) then LGAGBLK = 0; if CPARACE in (-1,.) then CAGHIS = . ; else if CPARACE = 3 then CAGHIS = 1; else if CPARACE in (1,2,4,7,8,9) then CAGHIS = 0; if LGPARACE in (-1,.) then LGAGHIS = . ; else if LGPARACE = 3 then LGAGHIS = 1; else if LGPARACE in (1,2,4,7,8,9) then LGAGHIS = 0; if CPARACE in (-1,.) then CAGASN = . ; else if CPARACE = 4 then CAGASN = 1; else if CPARACE in (1,3,2,7,8,9) then CAGASN = 0; if LGPARACE in (-1,.) then LGAGASN = . ; else if LGPARACE = 4 then LGAGASN = 1; else if LGPARACE in (1,3,2,7,8,9) then LGAGASN = 0; if CPARACE in (-1,.) then CAGOTH = . ; else if CPARACE in (8,9) then CAGOTH = 1; else if CPARACE in (1,2,3,4,7) then CAGOTH = 0; if LGPARACE in (-1,.) then LGAGOTH = . ; else if LGPARACE in (8,9) then LGAGOTH = 1; else if LGPARACE in (1,2,3,4,7) then LGAGOTH = 0; /** Whether units w/ same bedrooms as requested available to either tester **/ if ttyp in (1) and radaval > 0 then c_sim = 1; if ttyp in (2) and radaval > 0 then lg_sim = 1; /** Number of people encountered **/ if ragname1 ^= " " then person1 = 1; if ragname2 ^= " " then person2 = 1; if ragname3 ^= " " then person3 = 1; if ragname4 ^= " " then person4 = 1; if ragname5 ^= " " then person5 = 1; if ttyp in (1) then do; CPEOP = sum(of person1 person2 person3 person4 person5); if CPEOP = . then CPEOP = 1; end; else if ttyp in (2)then do; LGPEOP = sum(of person1 person2 person3 person4 person5); if LGPEOP = . then LGPEOP = 1; end; if ttyp in (1) then CTRACE = TRACE; if ttyp in (2) then LGTRACE = TRACE; run; /* Identify whether testers saw the same agent */ proc sort data = multi_tl_lgt (where = (ttyp = 1)) out = multi_tl_c; by control; run; proc sort data = multi_tl_lgt (where = (ttyp = 2)) out = multi_tl_lg; by control; run; data sameagent_lgt; merge multi_tl_c (keep = control CPARACE CPASEX CPAAGE CPANAME) multi_tl_lg (keep = control LGPARACE LGPASEX LGPAAGE LGPANAME); by control; CFL = substr(upcase(CPANAME),1,1); LGFL = substr(upcase(LGPANAME),1,1); UPCNAME = upcase(CPANAME); UPLGNAME = upcase(LGPANAME); UPCNAME2 = compress(UPCNAME); UPLGNAME2 = compress(UPLGNAME); if UPCNAME2 = UPLGNAME2 then SAMEAGNT = 1; else if (CPARACE = LGPARACE) and (CPASEX = LGPASEX) and (CPAAGE = LGPAAGE) /*and (CFL = LGFL)*/ then SAMEAGNT = 1; else SAMEAGNT = 0; drop UPCNAME2 UPLGNAME2; run; %let multvars = LESBIANTEST GAYTEST TRANSTEST REMOTE CONVEY CFIRST LGFIRST CAFTERNOON LGAFTERNOON CPEOP LGPEOP CCUREMP LGCUREMP CCURTENR LGCURTENR CEXPERNC LGEXPERNC CHIGHEDU LGHIGHEDU CHOMEHNT LGHOMEHNT CPEGAI LGPEGAI CAGE LGAGE CCHILD CMARRIED CAUDFEM CINCOME LGCHILD LGMARRIED LGAUDFEM LGINCOME CAGBLK LGAGBLK CAGHIS LGAGHIS CAGASN LGAGASN CAGOTH LGAGOTH CAGFEM LGAGFEM CAGAGE LGAGAGE testmonth BROOMS CTRACE LGTRACE CAGTGAY LGAGTGAY CBIRTHMALE CBIRTHFEMALE CCISMALE CCISFEMALE CTRANSMALE CTRANSFEMALE CGENDEROTH CSTRAIGHT CGAY CLESBIAN CBISEX CORIENTOTH LGBIRTHMALE LGBIRTHFEMALE LGCISMALE LGCISFEMALE LGTRANSMALE LGTRANSFEMALE LGGENDEROTH LGSTRAIGHT LGGAY LGLESBIAN LGBISEX LGORIENTOTH PWHITE_ID PHISPANIC_ID PBLACK_ID PASIAN_ID PDONT_KNOW_ID TIDENTIFIABLE_100 TIDENTIFIABLE_66 TIDENTIFIABLE_33; /** Summarize to control level **/ proc summary data = multi_tl_lgt; class control; var &multvars.; output out = multi_cl_lgt_sum (drop = _type_ _freq_) sum =; run; /** Control level cleaning **/ data multi_cl_lgt; merge multi_cl_lgt_sum (in=a) sameagent_lgt (keep = control SAMEAGNT) ; by control; if a; site = Substr(control,1,2); if control = " " then delete; /** Difference in age **/ AUDAGE = CAGE - LGAGE ; /** DIfference in order **/ NORDER = CFIRST - LGFIRST ; /** Difference in afternoon **/ AFTNOON = CAFTERNOON - LGAFTERNOON; /** Difference in tester employement **/ CUREMP = CCUREMP - LGCUREMP; /** Difference in tester homeownership **/ CURTENR = CCURTENR - LGCURTENR; /** Difference in tester experience **/ EXPERNC = CEXPERNC - LGEXPERNC; /** Difference in higher level of education **/ if CHIGHEDU = LGHIGHEDU then HIGHEDU = 0; else if CHIGHEDU > LGHIGHEDU then HIGHEDU = 1; else if CHIGHEDU < LGHIGHEDU then HIGHEDU = -1; /** Difference in whether looking for housing **/ HOMEHNT = CHOMEHNT - LGHOMEHNT; /** Difference in gross income **/ if CPEGAI = LGPEGAI then PEGAI = 0; else if CPEGAI > LGPEGAI then PEGAI = 1; else if CPEGAI < LGPEGAI then PEGAI = -1; /** Dummy for each site **/ if site = "DC" then DC_DUMMY = 1; else DC_DUMMY = 0; if site = "DL" then DL_DUMMY = 1; else DL_DUMMY = 0; if site = "LA" then LA_DUMMY = 1; else LA_DUMMY = 0; /** Dummy for month **/ if testmonth = 1 then JAN_DUMMY = 1; else JAN_DUMMY = 0; if testmonth = 2 then FEB_DUMMY = 1; else FEB_DUMMY = 0; if testmonth = 3 then MAR_DUMMY = 1; else MAR_DUMMY = 0; if testmonth = 4 then APR_DUMMY = 1; else APR_DUMMY = 0; if testmonth = 5 then MAY_DUMMY = 1; else MAY_DUMMY = 0; if testmonth = 6 then JUN_DUMMY = 1; else JUN_DUMMY = 0; if testmonth = 7 then JUL_DUMMY = 1; else JUL_DUMMY = 0; if testmonth = 8 then AUG_DUMMY = 1; else AUG_DUMMY = 0; if testmonth = 9 then SEP_DUMMY = 1; else SEP_DUMMY = 0; if testmonth = 10 then OCT_DUMMY = 1; else OCT_DUMMY = 0; if testmonth = 11 then NOV_DUMMY = 1; else NOV_DUMMY = 0; if testmonth = 12 then DEC_DUMMY = 1; else DEC_DUMMY = 0; /** Maximum people encountered by either teammate **/ if CPEOP = LGPEOP then NUMPEOP = CPEOP; else if CPEOP > LGPEOP then NUMPEOP = CPEOP; else if CPEOP < LGPEOP then NUMPEOP = LGPEOP; /** Difference between whether agent was black **/ AGBLK = CAGBLK - LGAGBLK; /** Difference betwen whether agent was hispanic **/ AGHIS = CAGHIS - LGAGHIS; /** Difference between whether agent was different age **/ if CAGAGE = LGAGAGE then AGAGE = 0; else if CAGAGE > LGAGAGE then AGAGE = 1; else if CAGAGE < LGAGAGE then AGAGE = -1; /** Difference between whether agent was female **/ AGFEM = CAGFEM - LGAGFEM; /** Difference in number of people encountered **/ DAGNUM = CPEOP - LGPEOP; drop testmonth site c_sim lg_sim; %makemissing (CHIGHEDU LGHIGHEDU CPEGAI LGPEGAI); run; proc sort data = multi_cl_lgt; by control ; run; /* Load the labels file */ proc import datafile="Y:\METRO\HDS-LGT\mlgt_labels.csv" out=mwclabels dbms=csv replace; getnames=yes; run; /* Set-up Codebook formats */ data codebook; set mwclabels; labelstatement = left(trim(name))||"="||""""||left(trim(label))||""""; run; proc sql noprint; select labelstatement into :labellist separated by " " from codebook; quit; /** Save Final dataset **/ data lgt_multi_merge; merge i.stackedremote ( keep = control c_testerid lg_testerid approved_flag anyavail_flag anyunit_flag meta_flag metagent_flag toldrent_flag shown_unit_flag c_any_avail lg_any_avail c_totaval lg_totaval c_rurent lg_rurent c_netcost lg_netcost c_rinspun lg_rinspun c_rutotfee lg_rutotfee c_rutotinctv lg_rutotinctv c_shown_any lg_shown_any c_consxorpt lg_consxorpt) multi_cl_lgt i.lgt_sec_tr i.lgt_sec ; by control; if approved_flag ^= .; site = substr(control,1,2); *label &labellist.; run; proc sort data = lgt_multi_merge out = i.lgt_mv; by control; run; /* End of Program */