x cd /pub/data/mable2k/Tools; %let pgm=genmable2k_01; filename pgm "&pgm..sas"; *--Generate the mable2k data base - 1st module. Here we just generate the basic sets for 1 or more states, using the SF1 2000 geographic headers datasets as our source.--; /* Update History 05-8-2002: Modifying the creation of the final state view to include data from the xxblks2 dataset. 01-15-2003: Rerunning for Missouri with library districts added. */ options msglevel=i fullstimer; libname mable2k '/pub/data/mable2k'; libname sf1geos '/pub/data/sf12000/xxgeos'; libname georef '/pub/data/georef' access=readonly; libname corrlst '/pub/data/corrlst' access=readonly; %let state=29; %let stab=mo; %let state=20; %let stab=ks; proc format library=library; value $SC2Alph '00'=' ' 01-04='A' 05-08='B' 09-11='C' 12-13='D' 14-15='E' 16-17='F' 18='G' 19-20='H' 21-23='I'; value $alphasc a,A='Less than 200' b,B='200-999' c,C='1000-2499' d,D='2500-9999' e,E='10,000-24,999' f,F='25,000-99,999' g,G='100,000-249,999' h,H='250,000-999,999' i,I='1,000,000+' ' '='Not in a place'; run; options mprint; %macro doit(state,stab); *---Create the block level dataset--; data mable2k.&stab.blks (sortedby=county tract block index=(county)); %if &state=29 %then %do; merge sf1geos.&stab.blks corrlst.mobl2house(keep=county tract block sldl rename=(sldl=sldl02)) corrlst.mobl2senate(keep=county tract block sldu rename=(sldu=sldu02)) corrlst.mobl2cd108(keep=county tract block cd108) corrlst.mobl2libd(keep=county tract block distcode rename=(distcode=libdist)) ; by county tract block; keep sldl02 sldu02 cd108 libdist; *<--extra MO only geocodes--; %end; %else %do; set sf1geos.&stab.blks; %end; if _n_=1 and state ne "&state" then do; put //'*******Dataset Problem: State Code read is ' state " but parm value specified is &state"; abort abend; end; retain PopDen '0 Empty'; if pop100=0 then PopDen='0 Empty'; else if areasqmi=0 then PopDen=' '; else do; *--the 7.5 and 6723 break points were the 10th and 90th percentiles of block densities for MO blocks with pop--; PoppSQMI=Pop100/AreaSQMI; if poppsqmi<=7.5 then PopDen='1 Low'; else if poppsqmi le 6723 then PopDen='2 Med'; else PopDen='3 High'; end; *--Recode CntySC and PlaceSC into 10 intervals with alpha codes--; CntySC=put(CntySC,$SC2Alph2.); PlaceSC=put(PlaceSC,$SC2Alph2.); format CntySC PlaceSC $alphasc.; keep popden cntysc placesc; keep county tract block cnty placefp cousubfp bg cd106 sldu sldl vtd zcta5 AreaSQMI LandSQMI Pop100 HU100 IntPtLat IntPtLon SDElm SDSec SDUni TAZ; length placece $4 cousubce $3; keep placece cousubce; length _arg $7 _arg2 $10; _arg=state||placefp; if placefp='99999' then placece='9999'; else placece=put(_arg,$fplccnv.); _arg2=county||cousubfp; cousubce=put(_arg2,$fmcdcnv.); label placece='Census Place Code' cousubce='Census County Subd. code'; length InPlace $1; *<--Indicates if in an incorporated place(1), a CDP(2) or not in a place(3).-; if placefp='99999' then InPlace='3'; else if placecc=:'C' then InPlace='1'; else InPlace='2'; keep InPlace; label Inplace='Indicates incorporated, CDP or not in a place'; %*--If the state is in New England we have to keep the msacmsa and pmsa codes at the block level--; %if %index(09 23 25 33 44 50,&state) %then %do; keep msacmsa pmsa masc cmsa2; %end; label Pop100='Total Pop, 2000 census' hu100='Total Hsg. Units, 2000 census'; rename Pop100=pop2k HU100=hus2k; run; *---Create the county level set with codes that do not vary within a county---; data mable2k.&stab.cocds1(label='County level geocodes from SF1 2000' sortedby=county index=(county)); %if &state=29 %then %do; merge sf1geos.&stab.geos(where=(SumLev='050') keep= sumlev county state stab region division msacmsa pmsa masc cmsa2 necma FuncStat lsadc Pop100 Hu100) georef.mocogeos(keep=county ded_region rpc dot msa90 cz90 lma90 beale umx2 rename=(ded_region=ded umx2=uoe)); by county; format county $5. ded $3. dot $2.; %end; %else %do; set sf1geos.&stab.geos(where=(SumLev='050') keep=sumlev county state stab region division %if %index(09 23 25 33 44 50,&state) eq 0 %then %do; msacmsa pmsa masc cmsa2 %end; necma FuncStat lsadc Pop100 Hu100); %end; rename Pop100=CoPop2k HU100=CoHUS2k FuncStat=CoFuncStat lsadc=CoLsadc; drop sumlev; run; *---And the view that combines the two...--; data mable2k.&stab.v/view=mable2k.&stab.v; merge mable2k.&stab.blks(in=inblks1) mable2k.&stab.blks2(in=inblks2 keep=county tract block ua ur ur90 puma5); by county tract block; if first.county then set mable2k.&stab.cocds1(rename=(county=countyck)); if county ne countyck then do; put "*************Error: county code on &stab.cocds1 dataset does not match that on the blks datasets****"; stop; end; run; *---Write a record to end of cnvtlog.txt documenting what we just did.---; data _null_; if 0 then set mable2k.&stab.blks nobs=n; file log; file "cnvtlog.txt" mod; put "Conversion for &stab&state complete on &sysdate at &systime . Census blocks processed: " n; stop; run; %mend doit; *dostates(01 02 04 05 06 08 09 10 11 12 13 15 16 17 18 19 20 21 22 24 25 26 27 28 29 30 31 32 33 34 35 36); *dostates(23 37 38 39 40 ); *dostates(41 42 43 44 45 46 47 49 50 51 53 54 55 56); *dostates(48); %dostates(29);