/* Generate the mable18 views used in the geocorr 2018 web application. This program merges three datasets created in previously run setups. */ %include '/pub/sas/autoexec.sas'; options fmtsearch=(mable18 sasctlgs); options nosource nosource2 nomprint nomlogic nosymbolgen nonotes; libname mable18 '/pub/data/mable18'; proc format library=mable18; 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; %macro doit(state,stab); /* This view combines (merges) the block-level data from the block datasets, the TIGER/Line faces files, and the cocds1 county-level data. */ data mable18.&stab.v/view=mable18.&stab.v; merge mable18.&stab.blks(in=inblks1) mable18.&stab.tgrlnfaces(in=inblks3); by state cnty tract block; if first.cnty then set mable18.&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****" county= countyck=; stop; end; if placefp14=' ' then placefp14='99999'; *-- for consistency with placefp (2010) ; if placefp18=' ' then placefp18='99999'; *-- for consistency with placefp (2010) ; if cbsa10 ne '99999' and cbsa10 ne ' ' then do; CbsaSC10=put(CbsaSC10,$SC2Alph2.); format Cbsasc10 $alphasc. ; if cbsatype10=" " then do; length _cbsaname $80; _cbsaname=put(cbsa10,$cbsa40.); if index(_cbsaname,'Micropolitan') then cbsatype10='Micro'; else cbsatype10='Metro'; end; end; if not (inblks1 and inblks3) then do; _missingbdata+1; *-- we allow missing data for the 2k data. There are a few in each state. ; if _missingbdata le 100 then put "Missing data for block: " inblks1= inblks3= cnty= tract= block=; else abort abend; end; drop countyck; drop _: ; run; *-- Write a record to end of cnvtlog.txt documenting what we just did. ; data _null_; set mable18.&stab.blks (obs=3) nobs=_nobs; file "cnvtlog.txt" mod; if _n_=1 then put "Conversion for &stab&state complete on &sysdate at &systime . Census blocks processed: " _nobs; *put / _all_ / ; stop; run; %mend doit; /* begin comment ==================================== %dostates(01 02 04 05 06 08 09 10 11 12 13 15 16 17); %dostates(18 19 20 21 22 23 24 25 26 27 28 29 30 31); %dostates(32 33 34 35 36 37 38 39 40 41 42); %dostates(44 45 46 47 48 49 50 53 54 55 56); %dostates(51); *-- found an error in MN (the CBSA code for Fairmont Micropolitan Area) so rerunning 2-25-16---; %dostates(27); *-- regenerating Arkansas (3-20-17) after finding problem with Hempstead co CBSA code. -; %dostates(05) ; ========================== end comment */ %dostates(05);