/* Adding 2025 school districts, Oct. 7, 2025. */ %include '/pub/sas/autoexec.sas'; options fmtsearch=(mable22 sasctlgs); options nosource nosource2 nomprint nomlogic nosymbolgen notes; libname mable22 '/pub/data/mable22'; libname updates '/pub/data/mable22/updates'; * Elementary ; %macro addELM(state,stab); proc sql; create table &stab._blocks as select t1.GEOID, t1.State, t1.County, t1.County3, %if &state = 09 %then %do; t1.CTcounty, %end; t1.CouSub23, t1.Place, t1.PlaceSC, t1.InPlace, t1.Tract, t1.BlockGroup, t1.Block, t1.NECTA, t1.NECTADiv, t1.CNECTA, t1.ConsCity, case when t2.ELSDLEA ne ' ' then t2.ELSDLEA else '99999' end label="Elementary school district (2025)" as SDElem25, t1.SDElem20, t1.SDSec20, t1.SDUni20, t1.SDBest20, t1.SDBestType20, t1.PUMA12, t1.PUMA22, t1.CD116, t1.CD117, t1.CD118, t1.CD119, t1.SLDU24, t1.SLDL24, t1.SLDU22, t1.SLDL22, t1.SLDU18, t1.SLDL18, t1.VTD20, t1.UA, t1.UR, t1.ZCTA, t1.HSA19, t1.HRR19, t1.AIANNH, t1.MOLibrary, t1.IntPtLat, t1.IntPtLon, t1.LandSQMI, t1.AreaSQMI, t1.pop20, t1.HUs20 from mable22.&stab._blocks t1 left join updates.sdelem25_for_mable t2 on (t1.GEOID = t2.GEOID); quit; data mable22.&stab._blocks; set &stab._blocks; run; proc sort; by county tract block; run; %mend addELM; * Secondary ; %macro addSEC(state,stab); proc sql; create table &stab._blocks as select t1.GEOID, t1.State, t1.County, t1.County3, %if &state = 09 %then %do; t1.CTcounty, %end; t1.CouSub23, t1.Place, t1.PlaceSC, t1.InPlace, t1.Tract, t1.BlockGroup, t1.Block, t1.NECTA, t1.NECTADiv, t1.CNECTA, t1.ConsCity, t1.SDElem25, case when t2.SCSDLEA ne ' ' then t2.SCSDLEA else '99999' end label="Secondary school district (2025)" as SDSec25, t1.SDElem20, t1.SDSec20, t1.SDUni20, t1.SDBest20, t1.SDBestType20, t1.PUMA12, t1.PUMA22, t1.CD116, t1.CD117, t1.CD118, t1.CD119, t1.SLDU24, t1.SLDL24, t1.SLDU22, t1.SLDL22, t1.SLDU18, t1.SLDL18, t1.VTD20, t1.UA, t1.UR, t1.ZCTA, t1.HSA19, t1.HRR19, t1.AIANNH, t1.MOLibrary, t1.IntPtLat, t1.IntPtLon, t1.LandSQMI, t1.AreaSQMI, t1.pop20, t1.HUs20 from mable22.&stab._blocks t1 left join updates.sdsec25_for_mable t2 on (t1.GEOID = t2.GEOID); quit; data mable22.&stab._blocks; set &stab._blocks; run; proc sort; by county tract block; run; %mend addSEC; * Unified ; %macro addUNI(state,stab); proc sql; create table &stab._blocks as select t1.GEOID, t1.State, t1.County, t1.County3, %if &state = 09 %then %do; t1.CTcounty, %end; t1.CouSub23, t1.Place, t1.PlaceSC, t1.InPlace, t1.Tract, t1.BlockGroup, t1.Block, t1.NECTA, t1.NECTADiv, t1.CNECTA, t1.ConsCity, t1.SDElem25, t1.SDSec25, case when t2.UNSDLEA ne ' ' then t2.UNSDLEA else '99999' end label="Unified school district (2025)" as SDUni25, t1.SDElem20, t1.SDSec20, t1.SDUni20, t1.SDBest20, t1.SDBestType20, t1.PUMA12, t1.PUMA22, t1.CD116, t1.CD117, t1.CD118, t1.CD119, t1.SLDU24, t1.SLDL24, t1.SLDU22, t1.SLDL22, t1.SLDU18, t1.SLDL18, t1.VTD20, t1.UA, t1.UR, t1.ZCTA, t1.HSA19, t1.HRR19, t1.AIANNH, t1.MOLibrary, t1.IntPtLat, t1.IntPtLon, t1.LandSQMI, t1.AreaSQMI, t1.pop20, t1.HUs20 from mable22.&stab._blocks t1 left join updates.sduni25_for_mable t2 on (t1.GEOID = t2.GEOID); quit; data mable22.&stab._blocks; set &stab._blocks; run; proc sort; by county tract block; run; %mend addUNI; * "best" SDs ; %macro addBest(state,stab); proc sql; create table &stab._blocks as select t1.GEOID, t1.State, t1.County, t1.County3, %if &state = 09 %then %do; t1.CTcounty, %end; t1.CouSub23, t1.Place, t1.PlaceSC, t1.InPlace, t1.Tract, t1.BlockGroup, t1.Block, t1.NECTA, t1.NECTADiv, t1.CNECTA, t1.ConsCity, t1.SDElem25, t1.SDSec25, t1.SDUni25, case when t1.SDUni25 ne ' ' then t1.SDUni25 when t1.SDElem25 ne ' ' then t1.SDElem25 when t1.SDSec25 ne ' ' then t1.SDSec25 end label="Best school district (2025)" length=5 as SDBest25, case when t1.SDUni25 ne ' ' then 'u' when t1.SDElem25 ne ' ' then 'e' when t1.SDSec25 ne ' ' then 's' end label="Best school district type (2025)" length=1 as SDBestType25, t1.SDElem20, t1.SDSec20, t1.SDUni20, t1.SDBest20, t1.SDBestType20, t1.PUMA12, t1.PUMA22, t1.CD116, t1.CD117, t1.CD118, t1.CD119, t1.SLDU24, t1.SLDL24, t1.SLDU22, t1.SLDL22, t1.SLDU18, t1.SLDL18, t1.VTD20, t1.UA, t1.UR, t1.ZCTA, t1.HSA19, t1.HRR19, t1.AIANNH, t1.MOLibrary, t1.IntPtLat, t1.IntPtLon, t1.LandSQMI, t1.AreaSQMI, t1.pop20, t1.HUs20 from mable22.&stab._blocks t1; quit; data mable22.&stab._blocks; set &stab._blocks; run; proc sort; by county tract block; run; %mend addBest; %macro updateViews(state,stab); * Create the views. ; data mable22.&stab.v/view=mable22.&stab.v; merge mable22.&stab._blocks mable22.&stab._counties ; by county; run; %mend updateViews; %dostates(n=52, mac=addELM); %dostates(n=52, mac=addSEC); %dostates(n=52, mac=addUNI); %dostates(n=52, mac=addBest); %dostates(n=52, mac=updateViews);