x cd /pub/data/mable14/Tools; %let pgm=alt_tractbg; filename pgm "&pgm..sas"; *---This job assigns alternate census tract and bg codes in 3 parts of the country (Pima co, AZ , LA county, CA and multiple cos in NY state. Basing the alternate values on http://www2.census.gov/geo/pdfs/reference/Geography_Notes.pdf viewed 12-2-15. We should be able to incorporate these as alternate geocodes to be added to mable14 and made accessible via geocorr14. (But have not yet done so!) Also can be used to add 2010 census data to ACS data at tract bg levels. The important output of this job is mable14.alt_sf1data which contains 2010 SF1 basic data (pop10, hus10, areasqmi, intptlat/lon) aggregated to current (i.e. post-2010 as used in ACS published data) tracts and bgs. Any affected bg or tract has updated data. If a tract code was used in the 2010 census but has now had a part of it assigned to a different tract then we have the new data for it in this data set. We should now use this data set when processing our ACS 5-year ustracts5yr and usbgs5yr data sets to incorporate these data. Important because our caps16acs and caps10acsb web apps used these data sets. J. Blodgett, OSEDA, MCDC 12-3-15 (start). Apparent final version 5-3-16. ---*; libname mable14 '/pub/data/mable14'; %libname(acs2013); title "&pgm.: Capture alternate tract and bg codes per Usage Notes Indicating problems with 2010 codes"; libname user '/SAS_temp/user'; proc format; *--define lookup format tables for ease of coding in 2 counties (Pima and Madison)--; *--alternate tracts, Pima co, AZ-; value $alttrpim 0027.01='0027.04' 0029.03='0029.06' 4105.01='0041.18' 4105.02='0041.21' 4105.03='0041.25' 4704.00='0052.00' 4705.00='0053.00' other=' '; *--altnerate tracts, Madison county, NY-; value $alttrma 9401.01='0301.01' 9401.02='0301.02' 9401.03='0301.03' 9402.00='0302.00' 9403.00='0303.00' 9404.01='0304.01' 9404.03='0304.03' 9406.00='0306.00' 9407.00='0304.02' other=' '; ; run; /*<=========================Comment out===================================== data mable14.&pgm(label="Blocks with tract or bg problems from 3 states"); length state $2 county $5 tract $7 bg $1 alttract $7 altbg $1; set mable14.azblks (where=(county='04019' and tract in ('0027.01','0029.03','4105.01','4105.02','4105.03','4704.00','4705.00'))) mable14.cablks (where=(county='06037' and tract in ('9304.01','8002.04'))) mable14.nyblks (where=(county in ('36053','36065','36085'))); if state='04' then do; alttract=put(tract,$alttrpim.); if alttract ne ' ' then altbg=bg; output; end; else if state='06' then do; if tract='8002.04' then do; alttract='1370.00'; if bg='3' then altbg='2'; else delete; end; ** value $blbgla 1000-1005,1007-1012,1016,1017,1019-1029="1" 3000-3029="2" other="0" ; if tract='9304.01' then do; alttract='1370.00'; if bg ne '1' then delete; if block in ('1006', '1013', '1014', '1015', '1018') then altbg='2'; else altbg='1'; end; output; end; else if state='36' then do; if county='36053' then do; *--Madison co, NY--; alttract=put(tract,$alttrma.); if alttract ne ' '; altbg=bg; end; if county='36065' then do; *--Oneida co, NY--; if tract='9400.00' then alttract='0248.00'; else if tract='9401.00' then alttract='0247.00'; else if tract='9402.00' then alttract='0249.00'; altbg=bg; if tract='0230.00' then do; if block in ('2035','2045','2046') then do; alttract='0249.00'; altbg='1'; end; else if block in ('2043','2044','2047','2048') then do; alttract='0249.00'; altbg='3'; end; end; end; if county='36085' then do; *--richmond co, NY--; if tract='0089.00' and bg='0' then do; alttract='0097.00'; altbg='0'; end; end; if alttract ne ' ' then output; end; *---NY processing---; keep state county tract bg block alttract altbg pop10 hus10 LandSQMI AreaSQMI IntPtLat IntPtLon; run; proc print data=&syslast (obs=50); by state county; format county $county.; title2 "&syslast"; id tract bg block; run; data altcodetracts; *--to be used in "pickoff merge" step to get just bgs that are alts--; set mable14.&pgm ; by county tract ; if first.tract; keep state county tract ; run; ===========================End commented out================================ */ *--Select all blocks from new ("alt") tracts/bgs and aggregate the 4 numerics to these new entities--; data mableblks; set mable14.azblks (where=(county='04019')) mable14.cablks (where=(county='06037')) mable14.nyblks (where=(county in ('36053','36065','36085'))); keep state county tract bg block pop10 hus10 landsqmi areasqmi intptlat intptlon; run; data mableblks2; merge mableblks altcodetracts(in=inaltcodes drop=intpt:); by county tract ; if inaltcodes; run; *---Now merge the subset of full mable but with just those tracts that experienced some alternate codes---; data mable14.mableblksalt(label='Alt blocks 2014 for PIMA AZ, LA cnty and 3 counties in NY'); merge mableblks2 (in=inmable) mable14.&pgm(in=inaltcodes); by county tract block; if alttract ne ' ' then tractACS=alttract; else tractACS=tract; if altbg ne ' ' then bgACS=altbg; else bgACS=bg; IntPtLon=IntPtLon*Pop10; IntPtLat=IntPtLat*Pop10; *--so we can get the weighted centroid--; label intptlon='Internal pt long weighted by pop10'; label intptlat='Internal pt lat weighted by pop10'; run; proc means data=mable14.mableblksalt noprint chartype; by state county; class tract tractACS bg bgACS; *types tract tract*bg tractACS tractACS*bgACS tract*tractACS tract*bg*tractACS*bgACS ( ); types tractACS tractacs*bgACS; var pop10 hus10 areasqmi landsqmi intpt: ; format areasqmi landsqmi 12.5; output out=mableblocksalt_sums sum= ; run; data mable14.alt_sf1data(label="Basic SF1 data for Tracts and BGs using ACS versions 2014"); set mableblocksalt_sums ; if _type_='0101' then SumLev='150'; else if _type_='0100' then SumLev='140'; else delete; drop tract bg; *--we keep only the ACs versions, TractACS and bgACS---; if pop10 then do; IntptLat=IntptLat/Pop10; IntPtLon=IntPtLon/Pop10; *--unweight--; end; drop _type_ _freq_; run; options ls=149; proc print data=mable14.alt_sf1data; by state county; format county $county.; id TractACS bgACS SumLev; title2 "mable14.alt_sf1data: Data aggregated to the ACS-consistent Tracts and BGs"; run;