x cd /pub/data/corrlst/Tools; %let pgm=cnvt_blkequivs_uscdslds2016; filename pgm "&pgm..sas"; /* We read the 3 equivalency files from Census Bureau with 2010 block to redrawn cds (115th) and state leg districts (as first used in 2012 elections). Modeled after mo-only module used to create the mo files much earlier. Raw data (zip files) used from www.census.gov/rdo/data/113th_congressional_and_new_state_legislative_district_plans.html jgb, 12-4-12 . */ %include '/pub/sas/autoexec.sas'; title "U.S. Congressional and State Legislative Districts for 2016."; %let set=uscdslds2016; libname user '/home/riceg/work'; libname corrlst '/pub/data/corrlst'; filename cds pipe "unzip -p ../CD115.zip National_CD115.txt" ; data cds; infile cds firstobs=2; input blockid $15. +1 cd115 $2.; run; proc sort; by blockid; run; filename sldls pipe "unzip -p ../SLDL_2016.zip National_2016SLDL.txt" ; data sldls; infile sldls firstobs=2; input blockid $15. +1 sldl $3.; run; proc sort; by blockid; run; filename sldus pipe "unzip -p ../SLDU_2016.zip National_2016SLDU.txt" ; data sldus; infile sldus firstobs=2; input blockid $15. +1 sldu $3.; run; proc sort; by blockid; run; filename cds clear; filename sldls clear; filename sldus clear; *-- Now combine the 3 into a single data set with the common block ID keys and the 3 new geocodes. ; data corrlst.&set(label='2010 block to 115th CDs and post-2015 SLDs for US' index=(state) compress=no); length State $2 County $5 Tract $7 Block $4; merge cds(in=in1) sldls(in=in2) sldus(in=in3) ; by blockid; state=substr(blockid,1,2); county=substr(blockid,1,5); tract=substr(blockid,6,4)||'.'||substr(blockid,10,2); block=substr(blockid,12,4); drop blockid; rename sldl=sldl16 sldu=sldu16; run; proc print data=corrlst.&set (obs=200); by state county; id tract; run; proc freq data=corrlst.&set; table state*cd115; run;