x cd /pub/data/acs2010/Tools; %let pgm=uszcta_allocation_basetable; filename pgm "&pgm..sas"; *---Allocate tract level basetbls data from the 2006-2010 ACS period estimates to ZCTAs using an equivalency file that comes from Geocorr10. We do this for whatever set of tables users request and store the results in basetbls.selected_zctatables . We do not attempt to aggregate the moe values for now. J. Blodgett, OSEDA, under contract with the Mo Census Data Center. May 14, 2012. Code revised and rerun 3-15-12. ---*; filename clistin '/pub/data/corrlst/uszip20102tract.csv'; libname btabs '/pub/data/acs2010/basetbls'; %let outset=mozctas5yrTablec17002; libname user '/SAS_temp/user'; /* ========================begin comment==================================== ==========================end comment====================================== */ data clist; infile clistin dsd termstr=crlf firstobs=2 truncover; length State $2 County $5 _tractin $6 ZCTA5 $5 Pop10 5 afact 8; input County -- afact; if county=:'29'; *<==============Missouri only===============; State=county; if zcta5 ne ' '; drop _: ; length tract $7; tract=substr(_tractin,1,4)||'.'||substr(_tractin,5,2); run; data tabledata; set btabs.motabs17_205yr(in=inacs keep=state county tract sumlev c17002i: rename=(county=county3 tract=tract6) ) ; *<========tables here====; where sumlev='140'; county=state||county3; tract=substr(tract6,1,4) ||'.' ||substr(tract6,5,2); drop county3 tract6; run; proc sort; by county tract; run; data aggin; merge clist(in=inclist where=(zcta5 ne ' ')) tabledata(in=inacs); by county tract; if inacs; SumLev='871'; *---state-ZCTA ---; keep sumlev state county tract zcta5 _numeric_; run; proc sort data=aggin; by state zcta5; run; %agg(aggin=aggin,aggout=aggout, aggvars=_numeric_ , byvars=state zcta5, idvars=Sumlev, means= , meanwts=, afacvar=afact, debug=0) ; run; data btabs.&outset(label="MO ZCTA summaries Table C17002 estimated by allocating from tract data. No MOEs" ); retain period '5yr' Years '2006-2010' State '29'; length areaname $64 esriid $7 Stab $2; set aggout; stab=put(state,$fipstab.); esriid=state||zcta5; areaname='ZCTA '||zcta5 || ' '||stab; if zcta5=' ' then do; areaname="Areas within "||trim(put(state,$state.))||" where no ZIP code is assigned"; esriid=state||'99999'; end; drop _: afact; run; proc contents data=btabs.&outset; run; proc means data= btabs.&outset n sum; by sumlev; class state; var c17002i:; run;