x cd /pub/data/dpro2010/Tools; %let pgm=age_report; filename pgm "&pgm..sas"; *---Genreate detailed breakdown by age. Shows 5 major cohorts 3 measures each. Macro used allows you to specify the state and the geographic units. jgb, 5-17-11 ---; %libname (dpro2010); options ls=160; options nodate; *******footnote h=1 "Report from the Mo Census Data Center Using 2010 Demographic Profiles Data"; ods listing close; %macro doit(state,stab); title color=brown "Basic Five Age Cohorts Report for &statenm"; footnote h=1 'The "%" cols show age cohort as % of total pop, while "% Female" is the % of the cohort that is female'; footnote2 h=1 "Report generated by MO Census Data Center on &sysdate from setup in &pgm..sas in dpro2010/Tools using acs2010.&stab.pros data"; ods html file="/pub/reports/agecohorts5_2010census/&statenm..html"; options orientation=landscape; ods pdf file="/pub/reports/agecohorts5_2010census/&statenm..pdf"; data report ; set dpro2010.&stab.pros; *****; * where sumlev='160' and pop100 ge 5000; where geocomp='00' and pop100; if sumlev='060' then do; length _cntyname $40; _cntyname=put(county,$county.); %chopwrd(_cntyname); Areaname=trim(_cntyname)|| ' Co. - '||Areaname; end; TotPop=pop100; age0_17=dpsf1i1 - dpsf4i1; pct0_17=100*age0_17/TotPop; F0_17=dpsf1i39-dpsf4i3; pctF0_17=100*F0_17/age0_17; age18_24=sum(of dpsf1i2-dpsf1i6) - Age0_17; pct18_24=100*age18_24/TotPop; F18_24=sum(of dpsf1i40-dpsf1i44) - F0_17; pctF18_24=100*F18_24/age18_24; age25_44=sum(of dpsf1i7-dpsf1i10); pct25_44=100*age25_44/TotPop; F25_44=sum(of dpsf1i45-dpsf1i48); pctF25_44=100*F25_44/age25_44; age45_64=sum(of dpsf1i11-dpsf1i14); pct45_64=100*age45_64/TotPop; F45_64=sum(of dpsf1i49-dpsf1i52); pctF45_64=100*F45_64/age45_64; ageover65=dpsf7i1; pctover65=100*ageover65/TotPop; Fover65=dpsf7i3; pctFover65=100*Fover65/ageover65; if "&state"="00" then state="00"; *<===weird stuff with national file---; keep state sumlev esriid areaname TotPop--pctFover65 ; label sumlev='Geographic Unit(s)' areaname='Geographic/Area'; *attrib pct0: pct1: pct2: pct4: pct5: pctOver format=5.1 label="%"; format pct: 5.1 age: comma9. totpop comma11.; ** attrib pctF: format=5.1 label="% Female"; ** attrib age: over65 format=comma9. label="Persons"; run; proc sort; by state sumlev esriid areaname; run; proc report data=report nofs headskip split='/' style(header)=[background=gray foreground=white font_face=helvetica font_weight=bold font_size=2] style(column)=[background=white foreground=black font_face=helvetica font_weight=bold font_size=2]; *** style(lines)=[foreground=white background=dark&color font_face=helvetica font_weight=bold font_size=3]; by sumlev; format sumlev $sumlev.; ***format state $state.; cols areaname TotPop ("Age 0-17" age0_17 pct0_17 pctF0_17) ("Age 18-24" age18_24 pct18_24 pctF18_24) ("Age 25-44" age25_44 pct25_44 pctF25_44) ("Age 45-64" age45_64 pct45_64 pctF45_64) ("Over 65" ageover65 pctOver65 pctFover65); define areaname /id display style(column)=[foreground=white background=#6699cc font_weight=bold font_face=arial] style(header)=[foreground=white background=gray]; define areaname / display flow ; define totpop / display "Total/Pop"; %macro defs(cohort); define age&cohort /display '#'; define pct&cohort/ display '%'; define pctF&cohort/ display '%/Female'; %mend defs; options mprint; %defs(0_17) %defs(18_24) %defs(25_44) %defs(45_64) %defs(over65) run; ods html close; ods pdf close; %mend doit; /* ==========================================begin comment================================== %dostates(11 12 21 23 25 26 28 35 38 44 45 47 54,names=1,msgs=1); %dostates(02 04 06 09 13 16 27 30 33 36 39 72 55,names=1,msgs=1); %dostates(01 08 10 15 20 29 31 32 37 42 49 53 56,names=1); %dostates(05 17 18 19 22 24 34 40 41 46 48 50 51 ,names=1); %let statenm=%str(United States); %doit(00,us) =========================================end comment======================================= */ %dostates(34,names=1)