x cd /pub/data/corrlst/Tools; %let pgm=cnvt_blkequivs_mocdslds2012; filename pgm "&pgm..sas"; *---We read the 3 euivalency files from Jim Harlan, GRC, sent via e-mail 12-2-11 . These 3 dbf files show correspondence of each Mo census block with the newly drawn 2012 congressional districts as well as the new (for 2012) state House and Senate districts. jgb, 12-3-11 . rev. 12-28-11 to incorporate update Senate data received from J Harlan rev. 4-30-12 to incorporate new (final) House and Senate codes. Replacing proc dbf with proc import. ---*; title "Missouri Legislative Districts for 2012. As of 4-3-2012"; libname user '/SAS_temp/user'; libname corrlst '/pub/data/corrlst'; title "&pgm.: Process Block Level Equvialency Files for Mo Legislative Districts"; *--We thought about merging the blocksgrcplus dataset in motrends with our output here but decided not to. That set has all the other geographic codes for 2010 plus 3 decades of basic demogrpahic counts-----*; ***libname motrends '/pub/data/pl942010/motrends'; *<---where GRC created a data trends file which we enhanced--; /* ========================begin comment==================================== *--the proc dbf steps were run interactively and results saved to user data lib-; filename cdsin "../GRANDCOMPROMISE.DBF"; proc dbf db4=cdsin out=cdsin; run; ==========================end comment====================================== */ ***filename housein "../HOUSE APPORTIONMENT PLAN.DBF"; filename housein "../HOUSE APPORTIONMENT PLAN.DBF"; proc import datafile=housein dbms=dbf out=user.housein; ***proc dbf db4=housein out=housein; run; ***filename senatein "../SENATE APPORTIONMENT PLAN.DBF"; ***proc dbf db4=senatein out=senatein; *** run; *** filename senatein "../sen11_blockequiv.DBF"; *<=====revised codes as received circa 12-7-11==; filename senatein "../FINAL SENATE PLAN 3 12 12.DBF"; *<=====revised codes as received 4-24-121==; proc import datafile=senatein dbms=dbf out=user.senatein; ***proc dbf db4=senatein out=senatein; run; data cds; set cdsin; length cd113 $2; cd113='0'||left(districtid); drop districtid; run; proc sort; by block; run; data house; set housein; length House12 $3; house12=left(districtid); drop districtid; run; proc sort; by block; run; data senate; set senatein; length Senate12 $3; senate12=left(districtid); drop districtid; run; proc sort; by block; run; data corrlst.moblk2cdslds2011(label='Missouri block to CD 513 and 2012 State Leg Districts'); merge cds(in=incds) house(in=inhouse) senate(in=insenate); by block; length County $5 Tract $7 Block4 $4; if not (incds and inhouse and insenate) then do; if not incds then _nocd+1; if not inhouse then _nohouse+1; if not insenate then _nosenate+1; _nbad+1; if _nbad le 100 then put _all_; end; County=substr(block,1,5); Tract=substr(block,6,4)||'.'||substr(block,10,2); block4=substr(block,12,4); *** if county gt '29001' then stop; *<======================================; drop block; rename block4=block; drop _: ; run; proc print data=_last_ (obs=200); by county; id tract block; run;