x cd /pub/data/acs2011/Tools; %let pgm=tempusbgs; filename pgm "&pgm..sas"; /*--Temporary setup to remove BG level data from the usmcdcprofiles5yr dataset and put them in usbgs5yr with many variables dropped that are never available at the BG level. J. Blodgett, OSEDA, Jan, 2013 Enhanced run 5-4-13 with updates from job newbgvar_formulae setup that generated lots of new values where before we had all missing values. E.g. the poverty data. -- */ title "&pgm"; title2 "Job to Temporarily Create a Separate BG data set but with some variables missing"; options compress=yes; libname acs2011 '/pub/data/acs2011'; libname acs (acs2011); libname user '/SAS_temp/userb'; filename nomatch "&pgm..nomatch.txt"; *---here we write messages indicating geos not matched between acs and sf1---; /* ========================begin comment==================================== *----We break the original usmcdcprofiles5yr dataset into 3 pieces: bgs, tracts and the rest.-----; data usbgsacsTemp(label='Temp blkgrp level data with limited variables' compress=no); retain vintage '2011'; *<===========================; length esriid $12 county $5 tract $7 bg $1; set acs2011.usmcdcprofiles5yr( drop=areaname zcta5 period years geocomp_name geocomp puma placefp FullTimeWorkers--poorOver65_moe Over16--EmployedFemales_moe HHPop--UMPartnerHHsPerK_moe Women15to50--GrandPrntsCaring5orMore_moe Over1--SpanishEnglishLTD_moe ); where sumlev='150'; esriid=substr(geoid,8); county=substr(geoid,8,5); tract=substr(geoid,13,4)||'.'||substr(geoid,17,2); BG=substr(geoid,19,1); drop geoid; label sumlev=' '; run; *---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 cbsa metdiv csa 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---; *******The plan is to rename this without the "2" once we know the setup is working***************************; data usbgs5yrtemp2( label="National 5-yr Summaries for BGs with SF1 data" ); update sf1xusbgs(in=insf1) usbgsacstemp(in=inacs where=(state ne '72')) end=_lastobs; by esriid; *drop geocode; retain _nomatch 0; retain cbsayr '2012'; *--Even though it comes from sf1 it is still current as of 12/12 ---; 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 _: ; label sumlev=' '; run; ==========================end comment====================================== */ *----------------This update step gets us the enhanced variables that before were all missing-------------------*; *---the code for ArmedForces and calcuating PctCivilian should have been done in the previous newbgvars_formulae job but we are too tired to go back and update that and start anew. So we stick it here. -----; data acs.usbgs5yrtemp2( index=(state) label="National 5-yr Summaries for BGs with SF1 data" ); update usbgs5yrtemp2 (in=inmaster) acs.newbgvars5yr(keep=esriid state vintage logrecnoC _numeric_ where=(state ne '72') in=innewvars) end=_lastobs; by esriid; if inmaster; if innewvars then do; ArmedForces=Over18 - Civilian; array nums(*) ManProfOccs ServiceOccs SalesOffOccs FarmFishOccs ConsOccs TransOccs Agriculture Construction Manufacturing WholesaleTrade RetailTrade Transportation Information Finance_ins Professional Educ_health_SocSvcs RecreationEtc OtherIndustries PublicAdmin PrivWageWorkers GovWorkers SelfEmpWorkers UnpaidFamWorkers Civilian ArmedForces; array pcts(*) PctManProfOccs PctServiceOccs PctSalesOffOccs PctFarmFishOccs PctConsOccs PctTransOccs PctAgriculture PctConstruction PctManufacturing PctWholesaleTrade PctRetailTrade PctTransportation PctInformation PctFinance_ins PctProfessional PctEduc_health_SocSvcs PctRecreationEtc PctOtherIndustries PctPublicAdmin PctPrivWageWorkers PctGovWorkers PctSelfEmpWorkers PctUnpaidFamWorkers PctCivilian PctArmedForces; if EmployedCLF then do _i=1 to dim(pcts); pcts{_i}=nums{_i}*100/EmployedCLF; end; end; format landsqmi 9.2; drop metrodiv; drop _i; run; data two; set acs.usbgs5yrtemp2(obs=2); run; proc fsbrowse printall data=two; title2 'acs.usbgs5yrtemp2'; *----------------This dataset is manually renamed to drop the "2" once we verify that this job worked------------*;