/************************************************************************* Program: LGT Inperson Macros.SAS Project: Housing Discrimination Study: Lesbian, Gay and Transgender Author: Brent Howell Created: 05/04/2015 Date Edited: 05/04/2015 Description: Constructs Macros that will be used in the telephone report analysis, the rental site visit analysis and the flags programs Output files: N/A **************************************************************************/ /***RECODE CLASSID TO IDENTIFY PROTECTED & CONTROL FOR TESTS***/ %macro protected; if classid in (11, 12, 13, 14, 15, 16, 17, 18) then protected = 1; else if classid in (21, 22, 23, 24, 25, 26, 27, 28) then protected = 0; %mend protected; %macro testtype; if testtype = 1 then lesbian_ip_w = 1; else lesbian_ip_w = 0; if testtype = 2 then lesbian_ip_m = 1; else lesbian_ip_m = 0; if testtype = 3 then gay_ip_w = 1; else gay_ip_w = 0; if testtype = 4 then gay_ip_m = 1; else gay_ip_m = 0; if testtype = 5 then lesbian_r = 1; else lesbian_r = 0; if testtype = 6 then gay_r = 1; else gay_r = 0; if testtype = 7 then trans_conv = 1; else trans_conv = 0; if testtype = 8 then trans_noconv = 1; else trans_noconv = 0; if testtype in (1, 2, 3, 4, 7, 8) then ip = 1; else ip = 0; if testtype in (1,2) then lesbian = 1; else lesbian = 0; if testtype in (3,4) then gay = 1; else gay = 0; if testtype in (7,8) then trans = 1; else trans = 0; %mend testtype; %macro testtype2 (); /*Create Substring Variable*/ str = substr(control,5,1); if str = "A" then testtype = 1; if str = "B" then testtype = 2; if str = "C" then testtype = 3; if str = "D" then testtype = 4; if str = "G" then testtype = 7; if str = "H" then testtype = 8; %mend testtype2; /* Recode missings to zero */ %macro fix_missing (fix); %let varlist = &fix.; %let i = 1; %do %until (%scan(&varlist,&i,' ')=); %let var=%scan(&varlist,&i,' '); if &var. = -1 or &var. = . then &var. = 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 fix_missing; %macro testing (dataset, variable); title Variable &variable. from &dataset; proc univariate data = &dataset.; var &variable.; class protected; run; %mend testing; %macro testing2 (dataset, variable); title Variable &variable. from &dataset; proc univariate data = &dataset.; var c_&variable. lg_&variable.; run; %mend testing2; /* Transpose tester ids */ %macro testerid(dset,mod); data rental_testers_in; set &dset.; %protected; keep control testerid protected; run; proc sort data = rental_testers_in; by control protected; run; proc transpose data = rental_testers_in out = renal_ttrans; by control; var testerid; run; data rental_tesers; set renal_ttrans; c_testerid_&mod. = col1; lg_testerid_&mod. = col2; keep control c_testerid_&mod. lg_testerid_&mod.; run; proc sort data = Rental_tesers; by control; run; %mend testerid; /***Preliminary Data Ouput***/ %macro output (testtype); data output; set ip_indicators; if &testtype. > 1; run; proc means data = output; title &testtype.; run; %mend; /*****Fix two Trans Tests That were inappropriately approved*****/ %macro fixtests(); /*Trans Tests that were approved for the appointment Stage but shouldnt have been because no appointment stage for Trans Tests*/ if control in ("DC-RG-2422-1" "DC-RG-3453-1") then ip = 0; %mend fixtests; /* End of Macro File */