x cd /pub/data/blkrel10/Tools; %let pgm=export_blk10_pumaur2k; filename pgm "&pgm..sas"; *----Followup to what we did in tep 2 of the cnvt_blkrel2010 setup. All we do is create a single output CSV file for export to bce to use in mabel/geocorr10. John Blodgett, OSEDA, U. of Missouri Outreach & Extension Jan 2012 ----*; %let datapath=%str(/pub/data/blkrel10/); libname blkrel10 '/pub/data/blkrel10'; libname mable10 '/pub/data/mable10'; *---We write some data sets here, where we relate 2010 blocks to selected 2k geos---; %macro dset(state,stab); blkrel10.&stab.blk10_2kgeos %mend dset; data mable10.tempblk2kgeos(label='See export_blk10_pumaur2k.sas in Tools'); set %dostates(n=51,mac=dset) open=defer; run; %macro dset2(state,stab); blkrel10.&stab.poptrend2010blks %mend dset2; data usblk2kpops; %dostates(n=51,mac=dset2); keep county tract blk totpop2k; run; *===================================Continue from here#####################################################################; data mable10.usblk10_2kgeopopss(sortedby=cnty tract blk label='2010 block to "primary" 2000 geographies' compress=Yes); length State $2 cnty $3 tract $7 blk $4 blksfx $1 Pop10 HUs10 5; set blks2; by cnty tract blk; *if substr(blk,2,2)='99' then delete; if last.blk; *---We keep the intersection with the largest AreaLandInt and if that is a tie then we use areawaterint to break it-; length bg2k $1; bg2k=substr(blk2k,1,1); run; ***Step 2C***; filename dlmout "/pub/data/mable10/&stab.blk10_2kgeos.csv"; %cnvtdlm(setin=mable10.&stab.blk10_2kgeos, names=1, charvars=state cnty tract blk cnty2k tract2k bg2k puma2k cousubfp2k placefp2k vtd2k taz2k ur2k ur90, quotes=0,hquotes=0, numvars=arealandint) run; %mend doit; options NOmprint; %dostates(n=51,names=1); %***dostates(10,names=1); run; /* ========================begin comment==================================== *-----------------------------------Part 3: -----------------------------------------------------------------; *----This phase does not need to rerun. If and when it does we may need to tweak the code since we slightly changed the variables on the blk2k_blk10 data set (replacing county with cnty variables). ---; *-----In this section we create the XXpoptrend2010blks data set with estimated 2k pop and pl94-based 2010 pop counts for current (i.e. 2010) blocks and with 2010 placefp and cousubfp codes. ---*; %macro doit(state,stab); proc sort data=blkrel10.&stab.bl2k_bl10(keep=county tract blk pop2kint) out=&stab.temppops; by county tract blk; run; %agg(aggin=&stab.temppops,aggout=pop2k_2010blks, aggby=county tract blk, aggvars=pop2kint, naggvars=1, debug=0); *---so now we have a data set with 2010 geos and 2k total pop counts aggregated. We now want to merge this our 2010 pl94 data and add some geocodes to create an aggin data set which we shall then use to create a whole hierarchy of summaries : county-tract-bg-block . ---; proc sort data= pl942010.&stab.sums(keep=state stab sumlev county tract block totpop tothus placefp cousubfp where=(sumlev='750') rename=(block=blk )) out=pl94sorted; by county tract blk; run; data aggin; merge pop2k_2010blks(in=in1) pl94sorted(in=in2010); by county tract blk; retain state "&state" stab "&stab"; if not in1 then TotPop2k=0; else TotPop2k=round(pop2kint); length bg $1; bg=substr(blk,1,1); label totpop='Total 2010 Pop' tothus='Total 2010 HUs'; drop sumlev pop2kint; run; proc means data=aggin noprint; id state stab; class county tract bg blk placefp cousubfp; types county * tract * bg *blk *cousubfp * placefp county*tract*bg county*tract county placefp county*placefp county*cousubfp ( ) ; var totpop tothus totpop2k ; output out=freqout sum=; run; data blkrel10.&stab.poptrend2010blks blkrel10.&stab.poptrend2010bgtrcopl(drop=blk); length State $2 County $5 SumLev $3; set freqout; select (_type_); when(63) SumLev='100'; *---census block summary but with placefp and cousbfp carried along--; when(56)SumLev='150'; when(48)SumLev='140'; when(32)SumLev='050'; when(0) SumLev='040'; when(2) SumLev='160'; when(34)SumLev='155'; when(33)SumLev='060'; end; *-- drop _freq_ _type_; if sumlev='100' then output blkrel10.&stab.poptrend2010blks; else output blkrel10.&stab.poptrend2010bgtrcopl; drop _type_ _freq_; run; %mend doit; %dostates(n=51) ; ==========================end comment====================================== */