x cd /pub/data/corrlst/Tools; %let pgm=cnvt_blkequivs_uscdslds2012; filename pgm "&pgm..sas"; *---We read the 3 equivalency files from Census Bureau with 2010 block to redrawn cds (113th) 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 . ---*; title "U.S. Congressional and State Legislative Districts for 2012."; %let set=uscdslds2012 ; libname user '/SAS_temp/user'; libname corrlst '/pub/data/corrlst'; %*macro doit(state,stab); %*let ustab=%upcase(&stab); *filename cds pipe "unzip -p ../CD113.zip &state._&ustab._CD113.txt" ; /* ========================begin comment==================================== filename cds pipe "unzip -p ../CD113.zip National_CD113.txt" ; data cds; infile cds firstobs=2; input blockid $15. +1 cd113 $2.; run; proc sort; by blockid; run; *filename sldls pipe "unzip -p ../SLDL_post2010.zip &state._&ustab._SLDL.txt" ; filename sldls pipe "unzip -p ../SLDL_post2010.zip National_SLDL.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_post2010.zip &state._&ustab._SLDU.txt" ; filename sldus pipe "unzip -p ../SLDU_post2010.zip National_SLDU.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; ==========================end comment====================================== */ *---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 113th CDs and post-2010 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=sldl12 sldu=sldu12; run; proc print data=corrlst.&set (obs=200); by state county; id tract; run; proc freq data=corrlst.&set; table state*cd113; run;