x cd /pub/data/acs2010/Tools; %let pgm=usbgprofiles; filename pgm "&pgm..sas"; %include '/pub/sas/autoexec.sas'; options compress=binary; libname acs2010 '/pub/data/acs2010'; libname sf12010x '/pub/data/sf12010x'; libname acs '/pub/data/acs2010'; libname user '/SAS_temp/userb'; *---we have 51 state-level sf1x datasets. Here we concatentate and shrink (selects vars) those sets.--; %macro setref(state,stab); sf12010x.&stab.bgs150(keep=esriid areaname state stab county tract bg intptlat intptlon LandSQMI AreaSQMI totpop totpop00 tothhs GQpop rename=(totpop=totpopsf1 GQpop=Gqpopsf1 tothhs=TotHHssf1)) %mend setref; data sf1xusbgs(compress=no); set %dostates(n=51,mac=setref) open=defer; run; data _null_; file nomtch; put; run; *---clear out file for do-over runs---; data acs.usbgs5yr( label="National 5-yr Summaries for BGs with SF1 data" ); update sf1xusbgs(in=insf1) acs.usbgs5yr(in=inacs) end=_lastobs; by esriid; retain _nomatch 0; label totpopsf1='2010 Census Total Pop count' tothhssf1='Total HHs 2010 Census count'; if not (inacs and insf1) then do; file nomatch mod; if _nomatch=0 then put / "Unmatched tempusbgs observations. As run at &sysdate &systime"; _nomatch+1; if _n_ gt 100 and _n_ - _nomatch < 20 then do; file log; put "***Too many non matches. Step aborting ****"; stop; end; if inacs then _msg="Not in SF1"; else _msg="Not in ACS"; put _msg +1 esriid= county= $county.; if not inacs then delete; end; if _lastobs and _nomatch then do; file log; put '**** ' _nomatch ' observations not matched between acs and sf1 '; end; drop _: ; run;