x cd /pub/data/mable12/Tools; %let pgm=usblk10_2kgeos; filename pgm "&pgm..sas"; *----Create a series of SAS block-level data sets using 2010 census blocks. It contains the "primary" 2000 geographic codes for each block, derived from the blkrel10 correspondence files as well as the 2000 census pop estimates also done using the blkrel10 data (see setup in blkrel10/Tools/ cnbvt_blkrel2010.sas ). Modeled after setup in mable10 where we jut created a csv file and passed it to bce for incorporation in mable10 database. jgb, 7-21-12. 1-22-13: Tweaking code so that we "impute" value of puma2k as value from previous block in same county. ----*; libname mable12 '/pub/data/mable12'; %libname(blkrel10); %macro doit(state,stab); **proc sort data=blkrel10.&stab.blks out=blks2 ; ***by state county tract blk arealandint areawaterint; ***run; proc sql; create view blks2 as select state||cnty as county, * from blkrel10.&stab.blks order by state, county, tract, blk, arealandint, areawaterint ; quit; data mable12.&stab.blk10_2kgeos(sortedby=state cnty tract blk label='2010 block to "primary" 2000 geographies' compress=No); length GeoKey $16 State $2 cnty $3 tract $7 blk $4 blksfx $1 TotPop2k 5; merge blks2(in=in1 ) blkrel10.&stab.poptrend2010blks(in=in2 keep=state county tract blk TotPop2k); by state county tract blk; if first.county then _curpuma2k=' '; *if substr(blk,2,2)='99' then delete; *** if in1; *--Replacing this line with the following 4, 1-22-14, jgb. Want to fix missing puma2k values--*; if in1 then do; _curpuma2k=puma2k; retain _curpuma2k; end; if not in1 then do; puma2k=_curpuma2k; puma2kimputed='Y'; end; *---New, 1-23-14---*; if cnty=' ' then cnty=substr(county,3,3); *<=====; if last.blk; *---We keep the intersection with the largest AreaLandInt and if that is a tie then we use areawaterint to break it-; GeoKey=state||cnty||trim(compress(tract,'.'))|| blk; *---the 2010 block geoid without the "10000US" part----; length bg2k $1; bg2k=substr(blk2k,1,1); *** keep GeoKey; keep state county cnty tract blk state2k cnty2k tract2k bg2k puma2k cousubfp2k placefp2k vtd2k taz2k ur2k ur90 TotPop2k; keep puma2kimputed; label TotPop2k='Est 2000 Pop for 2010 block'; run; %mend doit; %**doit(12,fl) ; options NOmprint; %dostates(n=51,names=1); %include sascode(notify);