x cd /pub/data/sf12000x/Tools; %let pgm=sf12kdata_by2010zctas; filename pgm "&pgm..sas"; *---User interested in 2000 census data (specifically persons 65+) by 2010 ZCTA geography. We need to use our sf12000x to get the 2k pop counts. We use the blkrel10.moblk2k_bl10 correlation list to attach 2010 blocks to the 2000 data. We use sf12010 headers data to get the 2010 ZCTA associated with the 2010 blocks. Then all we do is aggregate. Note that we aggregate the entire set of age cohort estimates - just as easy as doing a single variable. We also aggregate total pop (2000). jgb, per request from MO DHSS 4-14. ---*; libname user '/SAS_temp/userb'; libname sf12000x '/pub/data/sf12000x'; %libname(blkrel10); libname xxgeos '/pub/data/sf12010/xxgeos' access=readonly; title "&pgm : Aggregate Age Data from 2k Census to 2010 ZCTAs"; /*<=========================Comment out===================================== *---Step 1: Get the data to be aggregated. sf1 data 2k census at block level--; data pops2k; set sf12000x.moblks(Keep=county tract block totpop Age: Over65 rename=(county=county2k tract=tract2k block=blk2k) where=(totpop)); run; proc sort; by county2k tract2k blk2k; run; data with2010blks; *--merge with corr list to get 2010 census blocks---; merge pops2k(in=indata) blkrel10.mobl2k_bl10(drop=state2k state pop2kint in=inclist); by county2k tract2k blk2k; if indata; if not inclist then do; _nbad+1; if _nbad le 50 then put county2k= tract2k= blk2k= totpop= over65= ' ***Not on blkrel10 corr list***** '; else abort abend; delete; end; rename blk=block; *<---what we called it on the xxgeos data set so we go with latest--; drop _: ; run; proc sort; by county tract block; *--arange by 2010 geography--*; run; *---Step 2: Merge with the xxgeos data (MABLE basis) to get the ZCTA (2010) codes---; data aggin; length zcta5 $5; merge with2010blks(in=inblks in=indata) xxgeos.moblkgeos(keep=county tract block zcta5 in=inxxgeos); by county tract block; if indata; if not inxxgeos then zcta5='99999'; run; proc sort; by zcta5; run; %agg(aggin=aggin,aggout=aggout, aggby=zcta5, aggvars=_numeric_,afact=afact, dropvars=_lvl_, grand=1) ===========================End commented out================================ */ data sf12000x.ageby2010zctas (label='Special tab of 2000 age data to 2010 ZCTA'); length zcta5 $5 Areaname $32 Over65 5; set aggout (drop=afact); if zcta5=' ' then areaname='Missouri'; else areaname=put(zcta5,$zipname.); drop _nag_; format totpop comma9. over65 comma6. age0_4--age17_down 7.; run; proc print data=sf12000x.ageby2010zctas(obs=40); title2 "Partial Listing of sf12000x.ageby2010zctas"; footnote "From setup in sf12000/Tools/&pgm..sas"; id zcta5; run;