x cd /pub/data/pl942010/Tools; %let pgm=pl94_trend_reports; filename pgm "&pgm..sas"; *--You can delete this line-; *--- ----*; libname user '/SAS_temp/user'; libname pl942010 '/pub/data/pl942010'; *--This is the directory where the output data sets are saved--; libname pl94 (pl942010); *--alternate name---; libname pl942k '/pub/data/pl942000/othrstts' ; options orientation=landscape nodate; options linesize=160; %let maxobs=max; %let state=17; %let stab=il; %let statenm=Illinois; %let state=50; %let stab=vt; %let statenm=Vermont; %let state=24; %let stab=md; %global nstcnty10; *------Generate a series of trend reports using 2000 and 2010 PL94 datasets for geographies that do not need to be converted from 2k to 2010 units.---; %let rptvars=totpop over18 hisppop whitenh1 black1 asian1; %let rptvars2k=totpop2k over182k hisppop2k whitenh12k black12k asian12k; %**genrenam(pl942k.&stab.sums,xvars=sumlev state county placefp,sfx=2k); %**put rename=&rename; %let rename=%str( rename =( GeoCode=GeoCode2k AreaName=AreaName2k Stab=Stab2k Tract=Tract2k Region=Region2k Division=Division2k StateCe=StateCe2k Cnty=Cnty2k CntySC=CntySC2k CouSubFP=CouSubFP2k CouSubCC=CouSubCC2k CouSubSC=CouSubSC2k PlaceCC=PlaceCC2k PlaceDC=PlaceDC2k PlaceSC=PlaceSC2k BG=BG2k Block=Block2k ConCit=ConCit2k MSACMSA=MSACMSA2k MASC=MASC2k CMSA2=CMSA22k MACCI=MACCI2k PMSA=PMSA2k NECMA=NECMA2k UrbanRur=UrbanRur2k cd106=cd1062k sldu=sldu2k sldl=sldl2k vtd=vtd2k vtdi=vtdi2k ZCTA3=ZCTA32k ZIP=ZIP2k FuncStat=FuncStat2k gcuni=gcuni2k LSADC=LSADC2k PartFlag=PartFlag2k SDElm=SDElm2k SDSec=SDSec2k SDUni=SDUni2k TAZ=TAZ2k UGA=UGA2k PUMA5=PUMA52k PUMA1=PUMA12k _arg=_arg2k geo_id=geo_id2k LogRecNo=LogRecNo2k AreaLand=AreaLand2k AreaWatr=AreaWatr2k Pop100=Pop1002k IntPtLat=IntPtLat2k IntPtLon=IntPtLon2k LandSQMI=LandSQMI2k AreaSQMI=AreaSQMI2k TotPop=TotPop2k White1=White12k White2=White22k Black1=Black12k Black2=Black22k Indian1=Indian12k Indian2=Indian22k Asian1=Asian12k Asian2=Asian22k HawnPI1=HawnPI12k HawnPI2=HawnPI22k Other1=Other12k Other2=Other22k Whitenh1=Whitenh12k Whitenh2=Whitenh22k HispPop=HispPop2k Over18=Over182k WhOvr181=WhOvr1812k WhOvr182=WhOvr1822k BlOvr181=BlOvr1812k BlOvr182=BlOvr1822k InOvr181=InOvr1812k InOvr182=InOvr1822k AsOvr181=AsOvr1812k AsOvr182=AsOvr1822k HaOvr181=HaOvr1812k HaOvr182=HaOvr1822k OtOvr181=OtOvr1812k OtOvr182=OtOvr1822k WNOvr181=WNOvr1812k WNOvr182=WNOvr1822k HisOvr18=HisOvr182k MultRace=MultRace2k MROvr18=MROvr182k) ); %macro doit(state,stab); data temp2k; set pl942k.&stab.sums(&rename); where sumlev in ('040','050','155','160' ); keep sumlev areaname2k county placefp geocode2k &rptvars2k ; run; data stcnty2k stplace2k stcntyplace2k; set temp2k; if sumlev='040' then county="&state"; if sumlev='040' then output; if sumlev='050' then output stcnty2k; if sumlev in ('050','155') then do; if sumlev='050' then geocode2k=county; else geocode2k=placefp; output stcntyplace2k; end; if sumlev ='160' then output stplace2k; run; proc sort data=stcntyplace2k; by county placefp; run; data stcnty10 stplace10 stcntyplace10 ; **set pl94.&stab.sums(keep=sumlev areaname county cbsa placefp &rptvars LandSqmi ngeo_id); *** merge pl94.&stab.geos (where=(sumlev in ('040','050','155','160' )) in=ingeo) pl94.&stab.sumsng ; *** by ngeo_id; *** if ingeo; set pl94.&stab.sums; where sumlev in ('040','050','155','160' ); keep sumlev areaname county cbsa placefp &rptvars LandSqmi geocode; if sumlev='040' then county="&state"; if sumlev='040' then output; if sumlev='050' then output stcnty10; if sumlev in ('050','155') then do; if sumlev='050' then geocode=county; else geocode=placefp; output stcntyplace10; end; if sumlev ='160' then output stplace10; drop ngeo_id; run; proc sort data=stcntyplace10; by placefp; run; data stcntyplace10; set stcntyplace10; by placefp; if first.placefp and last.placefp then do; _ix=index(areaname,'(part)'); if _ix then substr(areaname,_ix)=' '; end; run; proc sort data=stcntyplace10; by county placefp; run; %macro genrset(rfile,rno); data &rfile&rno; merge &rfile.2k(in=in2k ) &rfile.10(in=in10); %if &rno=1 %then %str( by county; ); %if &rno=2 %then %str(by placefp;); %if &rno=3 %then %str(by county placefp;); **if not in10 then put "**Geography on pl942000 but not on pl942010*** " sumlev= areaname= county=; ** else if not in2k then put "**Geography on pl942010 but not on pl942000*** " sumlev= areaname= county= placefp=; if totpop then do; PctOver18=100*Over18/Totpop; PctHisppop=100*hisppop/Totpop; PctWhitenh1=100*whitenh1/totpop; PctBlack1=100*black1/totpop; PctAsian1=100*asian1/totpop; end; if totpop2k then do; PctOver182k=100*Over182k/Totpop2k; PctHisppop2k=100*hisppop2k/Totpop2k; PctWhitenh12k=100*whitenh12k/totpop2k; PctBlack12k=100*black12k/totpop2k; PctAsian12k=100*asian12k/totpop2k; end; if in10 and in2k then do; Popchange=totpop-totpop2k; if totpop2k then PctPopChange=100*Popchange/totpop2k; end; if not in10 then do; geocode=geocode2k; areaname=areaname2k; end; drop areaname2k; if landsqmi then PopPSQMi=totpop/Landsqmi; format pct: 5.1 PopPsqmi 7.1; run; %mend genrset; %genrset(stcnty,1); %genrset(stplace,2); %genrset(stcntyplace,3); ods listing close; %macro dorept(rtype); %local rno rfilename; %let rno=%substr(&rtype,1,1); %if &rno=1 %then %let rfilename=stcnty1; %else %if &rno=2 %then %let rfilename=stplace2; %else %if &rno=3 %then %let rfilename=stcntyplace3; title "&statenm Trend Report &rtype"; footnote h=1 "Generated on &sysdate from setup in pl942010/Tools/pl94_trend_reports.sas"; ***ods pdf file="/pub/reports/pl94trends/&statenm._&rfilename..pdf" notoc style=sasweb; ods html file="/pub/data/pl942010/trends/&statenm._&rfilename..html" style=sasweb; proc report data=&rfilename (obs=&maxobs) split='/' headline headskip spacing=1 ls=160 ps=60; columns %if &rno=1 %then %do; ('-Geography-' areaname county ) %end; %if &rno=2 %then %do; ('-Geography-' areaname placefp) %end; %if &rno=3 %then %do; ('-Geography-' areaname geocode) %end; ('-2010-' ('-Total Pop-' totpop popchange pctpopchange) /* ('-Over 18-' over18 pctover18) */ ('Race Alone' ('White Non-hispanic' whitenh1 pctwhitenh1) ('Black' black1 pctblack1) ('Asian' asian1 pctasian1) ) (' ' ('Hispanic' hisppop pcthisppop)) ) ('-2000-' totpop2k /* ('-Over 18-' over18 pctover18) */ ('Race Alone' ('White Non-hispanic' whitenh12k pctwhitenh12k) ('Black' black12k pctblack12k) ('Asian' asian12k pctasian12k) ) ('Hispanic' hisppop2k pcthisppop2k) ); define areaname / style={backgroundcolor=royalblue color=white} format=$char32. 'Area/ Summarized'; define county / 'FIPS' spacing=0 style={backgroundcolor=royalblue color=white} format=$5. width=5; define placefp / display style={backgroundcolor=royalblue color=white} format=$5. width=5 'FIPS'; define geocode / display style={backgroundcolor=royalblue color=white} format=$5. width=5 'FIPS'; define totpop/display spacing=1 format=comma10. 'Count'; define popchange/display spacing=1 format=comma8. 'Change'; define pctpopchange/display spacing=1 format=5.1 '%' ; * define over18 /display 'Count' format=comma10.; * define pctover18 /display '%' spacing=1 format=5.1; define whitenh1 /display 'Count' format=comma10.; define pctwhitenh1 /display '%' spacing=1 format=5.1; define black1 /display 'Count' format=comma9.; define pctblack1 /display '%' spacing=1 format=5.1; define asian1 /display 'Count' format=comma9.; define pctasian1 /display '%' spacing=1 format=5.1; define hisppop /display 'Count' format=comma9.; define pcthisppop /display '%' spacing=1 format=5.1; define totpop2k /display 'Total Pop' format=comma10.; define whitenh12k /display 'Count' format=comma10.; define pctwhitenh12k /display '%' spacing=1 format=5.1; define black12k /display 'Count' format=comma9.; define pctblack12k /display '%' spacing=1 format=5.1; define asian12k /display 'Count' format=comma9.; define pctasian12k /display '%' spacing=1 format=5.1; define hisppop2k /display 'Count' format=comma9.; define pcthisppop2k /display '%' spacing=1 format=5.1; run; ods html close; %mend dorept; %dorept(1: State and Counties); %dorept(2: State and Complete Places); %dorept(%str(3: State, Counties and Places Within Counties)); %mend doit; /* ========================begin comment==================================== %dostates(01 05 08 10 15 17 18 19 20 22 24 28 29 31 34 37 40 41 46 48 49 50 51 53 56,names=1); %dostates(06,names=1); %dostates(04 09 16 39 42 55,names=1); %dostates(01 05 08 10 15 18 19 20 22 24 28 31 34 37 40 41 46 48 49 50 51 53 56,names=1); %dostates(02 10 11 13 21 23 25 26 27 30 33 35 36 38 44 45 47 54 72,names=1) ; *--3-25-11 (final states)--; ==========================end comment====================================== */ %dostates(12,names=1);