x cd /pub/data/popests/Tools; %let pgm=ctychar_tabulate; filename pgm "&pgm..sas"; *--Custom tabsd off the mo single-years-of-age dataset. User wants: ...a spreadsheet containing population estimates by county for those under 18 and those that are 18 and older? 11/04, jgb --*; %let year=2003; %let yr=%substr(&year,3,2); libname popests "/pub/data/popests"; libname georef '/pub/data/georef' access=readonly; filename dlmout '/pub/data/temp/dmhests.csv'; *<=====================output file=======; filename htmlout '/pub/data/temp/dmhests.html'; title "&pgm : Tabulate MARS File With Data by Single Years of Age"; x cd /pub/data/popests; *<====; %let state=29; %let stab=mo; *<---in cased we ever want to modify for some other state--; %let set=&stab.ctychar&yr; proc format; value age 0-17='0-17' 18-high='18 and over'; run; proc means noprint data=popests.moctychar&yr(keep=county age year estimate where=(year='2003')); var estimate; class county age; types county*age ()*age; format age age.; output out=totals(drop=_freq_) sum= ; run; proc sort; by _type_ county age; data togo; set totals; by _type_ county age; length fipco 8; fipco=county; format fipco $5. county $mocnty.; if first.county then Under18=estimate; retain Under18; if last.county then do; over18=estimate; Total=Under18+Over18; PctUnd18=100*Under18/total; format PctUnd18 5.1; if county= ' ' then do; county='29'; fipco='29'; end; output; end; keep fipco county Under18 Over18 total PctUnd18 year; run; ods html file=htmlout; proc print data=togo; run; %cnvtdlm(setin=togo,round=.1); ods html close; data _null_; infile dlmout obs=12; input; list; run;