x cd /pub/data/sf12000/Tools; %let pgm=agersexh_query5; filename pgm "&pgm..sas"; *---Use the sf1.agersexh data to handle following query: From Sandrra Martin, Mo Inst. of Mental Health, St. Louis 3/04: Needs # of females in MO aged 12-17 outside KC and St Louis MSAs ---; title 'Missouri Female Population Aged 12-17 by County and Metro Area'; title2 'Source: 2000 Census Summary File 1'; *--Save output for web access in html format--; ods html file="/pub/reports/temp/martin.html" style=sasweb; title 'Count of Females Aged 12-17 from 2000 Census'; title2 'Missouri By County and Metro Area With State Totals'; libname georef '/pub/data/georef' access=readonly; libname sf1 '/pub/data/sf12000'; libname user '/SAS_temp/user'; options missing='0'; *<---so the cells with no data print as 0's instead of .'s--; options nodate; /*<=========================Comment out===================================== data query5; set sf1.moagersexh; by county; where sex='f' and race=' ' and hispanic=' ' and (12 <= age <= 17); if first.county then NF1217=0; NF1217 + Persons; keep county nf1217; if last.county then output; run; ===========================End commented out================================ */ data merged; merge query5(in=in5) sf1.mogeos(keep=county sumlev msacmsa where=(sumlev='050') in=ingeo); by county; drop sumlev; run; proc sort; by msacmsa; run; proc print data=merged label; by msacmsa; id msacmsa; format county $mocnty. msacmsa $metro.; sum nf1217; format nf1217 comma12.; label nf1217 ='Females Aged 12-17' msacmsa='Metro Area'; run; footnote 'Generated by setup in ' 'sf12000/Tools/agersexh_query5.sas' ' Using Data from SF1, MO'; run;