x cd /pub/data/popests/Tools; %let pgm=aggnchstocbsa; filename pgm "&pgm..sas"; *--Per request from RB, we aggregate the latest nchs estimates for Mo to CBSAs and broad age cohorts--; libname popests '/pub/data/popests'; libname georef '/pub/data/georef' access=readonly; proc summary data=popests.monchsbridged20xx_sumry; by year; where sumlev='050' and year='2005' and age ne ' '; class age_cohort1 county; types age_cohort1*county county; var total; output out=cntysums sum=totpop; run; proc sort data=cntysums; by county; run; proc print data=cntysums(obs=200); title 'cntysums'; run cancel; data mocbsas_byage_2005; merge cntysums georef.cbsacos(where=(state='29') keep=state county cbsa cbsatype cbsaname); by county; if cbsa ne ' '; run; proc print data=mocbsas_byage_2005(obs=50); title 'mocbsas_by_age'; run cancel; proc summary nway data=mocbsas_byage_2005; class cbsa cbsatype age_cohort1 /missing; id year state cbsaname; where cbsatype='Metro'; var totpop; output out=popests.mocbsas_byage(drop=_:) sum=; run; proc print data=popests.mocbsas_byage; by state year; id cbsa; run;