x cd /mscdc/data/georef/Tools; %let pgm=cbsas00_report; filename pgm "&pgm..sas";
*--create a report showing the propsed CBSAs by state with the latest (7-99) population
estimates. The reports include all counties, even those that would not be included in
any of the new metro/micro politan areas. See cbsas00.sas for creation of input sets.
jgb, Oct. 2000.
--*;
libname georef '/mscdc/data/georef' access=readonly;
libname popests '/mscdc/data/popests' access=readonly;
libname user v6 '/tmp/storage/user';
filename report '/SAS_temp/allstates.txt';
filename report2 '/wwwhome/mscdc/reports/cbsas00/allstates.txt';
proc printto print=report new;
options formdlim='=';
*ods html path="/wwwhome/mscdc/reports" (URL=none)
frame="cbsas00.frame.html"
contents="cbsas00.contents.html" body="cbsas00.body.html";
options mprint;
*odshtml(cbsas00) ; *--should generate same code as above commented out stmt--;
options nomprint;
options ls=125 ps=120 nodate center;
title 'Components and Populations of Preliminary Core Based Statistical Areas';
title2 'Source: http://www.census.gov/population/estimates/metro-city/cbsa/cbsa-alpha.txt';
title3 "
Report Produced by the
Missouri Census Data Center";
/*<==============Comment out==================================
*----combine the county level cbsa data with the latest fscpe pop estimates----*;
data report;
merge georef.cbsacos(in=incbsa)
popests.uscom99(in=inests keep=slvl state stab county popest popchang msacmsa areaname where=(slvl='050'));
by state county;
if not inests then do;
file print;
put state= county= ' not in estimates file.';
file log;
end;
drop slvl cnty areaname;
format county $county.;
fipco=county;
run;
proc sort; by cbsa; run;
data report2;
merge report(in=in1)
georef.cbsas(in=in2);
by cbsa;
sortstat=state; *--state for sorting report. If a county is in a cbsa that spans states
then it needs to be written multiple times with different sortstat values;
if not in2 then cbsatype='none';
output;
if in2 and nstates gt 1 then do;
savestab=stab;
do i=1 to nstates;
stab=scan(states,i);
if stab ne savestab then do;
sortstat=put( stfips(stab), z2.); *--e.g. stab='CT' fipstab(CT)=9 sortstab='09' -;
output;
end;
end;
end;
run;
proc sort data=report2 out=report(index=(sortstat));
by sortstat cbsatype cbsa metrodiv county;
run;
=============end comment====================================== */
%macro doit(state,stab);
ods html close;
ods html style=d3d body="/wwwhome/mscdc/reports/cbsas00/&stab..html";
title4 "&statenm";
proc print data=report(where=(sortstat="&state")) split='/';
by cbsatype cbsa cbsaname;
id cbsatype cbsa cbsaname;
%*--we include the metropolitan divsion variable only for the 4 states where it pertains-;
var %if %index(06 34 36 42,&state) %then %str( metrodiv );
county fipco popest popchang;
label sortstat='State'; format sortstat $state.;
label cbsatype='CBSA / Type'
fipco='FIPS /County' county='County' cbsa='CBSA / Code' cbsaname='CBSA Name'
popest='Population/Estimate/July, 1999'
popchang='Est. Pop/Change/1990-99';
format popest comma11. popchang comma9.;
sumby cbsa;
sum popest popchang;
run;
%mend doit;
%dostates(names=1)
*--edit the title3 out of the allstates.txt report file--;
proc printto; run;
data _null_;
infile report; file report2;
input;
if left(_infile_)=:'