x cd /pub/data/acs2012/Tools; %let pgm=usbgprofiles_checks; filename pgm "&pgm..sas"; /*--We look at the acs.usbgs5yr data set created by setup in usbgprofiles.sas. J. Blodgett, OSEDA, May, 2014 . We want to "check" the BG data set by: 1. comparing data for Del Ray CA CDP with corr BG to see if values match. 2. We aggregate our BG data to tracts for MO and compare the tract as converted with out BG aggregates to see how close. -- */ title "&pgm"; options compress=no; %let vintage=2012; libname acs2012 '/pub/data/acs2012'; libname acs (acs&vintage); libname user '/SAS_temp/userb'; /*<=========================Comment out===================================== data delraycdp; set acs.usplaces5yr( drop=stab county cbsa--BTBG FullTimeWorkers--pctPoorOver65 Over16--pctEmployedFemales Women15to50--pctGrandPrntsCaring5orMore TotPopNonInst--pctDisabledElder Over1--pctSpanishEnglishLTD TotPop_moe--CashRenterOver750_moe ); *---Fow now, we shall only look at the estimates and will ignor the MOEs----; where state='06' and placefp='18674'; *--Del Ray CDP, CA --; where also sumlev='160'; drop sumlev; **put _all_; drop esriid areaname; run; data testbg; set acs.usbgs5yr(drop=vintage esriid areaname stab TotPop00--CBSAYr TotPop_moe--CashRenterOver750_moe); where state='06' and county='06019' and tract='0069.00' and bg='1'; **put _all_; run; data both; set delraycdp testbg; run; proc compare base=testbg compare=delraycdp fuzz=.01 novalues; run; proc print data=both; format pct: 5.1; run ; ===========================End commented out================================ */ *---The second check involves aggregating BG data within tracts for one large county and comparing tract summaries with the aggregated-from-bg values----; data bgaggin; set acs2012.usbgs5yr(where=(state='29' and county='29189' and TotPop) drop=TotPop_moe--CashRenterOver750_moe Logrecno); run; options NOmprint ; %include '/pub/data/acs/Tools/aggvarparms2012bg.sas'; %agg(aggin=bgaggin,aggout=bgaggout, aggby=county tract, aggvars=_numeric_,agglvl=2, means=intptlat intptlon &acsmeansbg &pctvarsbg , meanwts=totpop totpop &acsmwgtsbg &pctwtsbg, debug=1) run; data tracts; set acs2012.ustracts5yr(where=(state='29' and county='29189' and TotPop) drop=totpop_moe--CashRenterOver750_moe); run; proc compare base=tracts compare=bgaggout(where=(_lvl_=1)) listequalvar criterion=.01 out=compare_out; id county tract; run; data counties; set acs2012.usstcnty5yr(where=(state='29' and county='29189') drop=totpop_moe--CashRenterOver750_moe); run; data countydata; set bgaggout(where=(_lvl_=2)) counties; format pct: 7.3 median: avg: 11.3; run; proc print data=countydata; title "Comparison of BG aggregate to County Level w County Data"; run;