/* Use this code template for all future mable22 updates. It retains the old CT counties (in the ct_blocks dataset). To use: 1. Make a copy of this program. 2. Create a dataset containing the geocodes and the field(s) needing updating / adding. This is T2. 3. Put the T2 dataset in the /data/mable22/updates directory. 4. Adjust the code below to pull the new / updated field(s) from T2, keeping all the other fields from T1 (the original). 5. Check the log for errors. 6. Delete the update dataset after succesful run. */ %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'; %macro doit(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.SDElem20, t1.SDSec20, t1.SDUni20, t1.SDBest20, t1.SDBestType20, t1.PUMA12, t1.PUMA22, t1.CD116, t1.CD117, t1.CD118, t1.CD119, t1.SLDU24, t2.SLDLST label="State legislative district, lower (2024)" as 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.[block_additions_DS] t2 on (t1.GEOID = t2.GEOID); quit; data mable22.&stab._blocks; set &stab._blocks; run; proc sort; by county tract block; run; * Create the views. ; data mable22.&stab.v/view=mable22.&stab.v; merge mable22.&stab._blocks mable22.&stab._counties ; by county; run; %mend doit; /* begin comment ==================================== %dostates(01 02 04 05 06 08 09 10 11 12 13 15 16 17); %dostates(18 19 20 21 22 23 24 25 26 27 28 29 30 31); %dostates(32 33 34 35 36 37 38 39 40 41 42); %dostates(44 45 46 47 48 49 50 53 54 55 56); %dostates(51 72); %dostates(10 11); ========================== end comment */ %dostates(n=52);