x cd /mscdc/data/georef/Tools; %let pgm=cbsas00; filename pgm "&pgm..sas"; *--create data sets with info regarding Core Based Statistical Areas as posted on Bureau web page, fall 2000. These definitions are not final - just tentative based on proposed (not yet final) guidelines and using 1990 census data. The official CBSA's will not be created until 2003. jgb, Oct, 2000. --*; filename in URL 'http://www.census.gov/population/estimates/metro-city/cbsa/cbsa-alpha.txt'; filename savein '/mscdc/data/georef/cbsa-alpha.txt'; libname georef '/mscdc/data/georef'; title 'Create georef Data Sets Related to Core Based Stat Areas, 2000'; data cbsas( keep=cbsa cbsaname cbsatype nstates states) cbsacos(keep=stab state cnty county cbsa metrodiv); infile in end=last truncover length=l; **** obs=200; retain; flag=0; retain cbsa ' '; length state stab $2 county $5 cnty $3 cbsaname $64; do until(flag); input newcbsa $1-3 line $84.; file savein ; l=l-1; *--to drop extra delimiter character at end of line; if l >1 then put _infile_; else put; file log; if length(newcbsa)=3 and verify(newcbsa,'0123456789')=0 then flag=1; length metrodiv $28; label metrodiv='Metropolitan Division'; _ix=index(line,'Metropolitan Division'); if _ix then metrodiv=substr(line,1,_ix-1); end; if cbsa ne newcbsa then do; if _n_ gt 1 then output cbsas; cbsa=newcbsa; ix =index(line,'(micro' ); if ix then do; cbsatype='micro'; end; else do; ix=index(line,'(metro'); cbsatype='metro'; end; cbsaname=substr(line,1,ix-1); states=' '; length nstates 3; nstates=0; curstab=' '; metrodiv=' '; end; else do; *--process county detail line--; stab=substr(line,25,2); if stab ne curstab then do; if states=' ' then do; nstates=1; states=stab; end; else if index(states,stab)=0 then do; nstates+1; states=trim(states)||' '||stab; end; curstab=stab; end; county=substr(line,29,5); format county $county.; *--special edit to make county codes consistent with those used on latest pop estimates; if county='12025' then county='12086'; *--miami-dade county, formerly just dade-; state=substr(county,1,2); cnty=substr(county,3,3); output cbsacos; end; if last then output cbsas; if _n_ le 10 then put / _all_; return; run; proc sort data=cbsas out=georef.cbsas(index=(cbsa) label='Tentative Core Based Stat Areas '); by cbsa; run; proc sort data=cbsacos out=georef.cbsacos(index=(state cbsa) label='Counties by CBSA'); by state county; run; proc sql; *--create view that merges the 2 data sets by cbsa--; create view georef.cbsacomb as select * from cbsas as cbsa, cbsacos as cos where cbsa.cbsa=cbsacos.cbsa order by state, cbsa, county; quit; proc print data=georef.cbsas(obs=100); title2 'georef.cbsas'; id cbsa; run; proc print data=georef.cbsacos(obs=100); title2 'georef.cbsacos'; by state; id county; run; proc print data=georef.cbsacomb; title2 'georef.cbsacomb - Missouri Subset'; by cbsa cbsaname; id cbsa cbsaname; where state='29'; run; proc contents data=georef.cbsas; proc contents data=georef.cbsacos; proc contents data=georef.cbsacomb; run;