x cd /pub/data/acs2011/Tools; %let pgm=newbgvar_formulae; filename pgm "&pgm..sas"; *---Develp and test new formulae for deriving variables from the base tables datasets at BG level. We actually do the test run here using the US totals just to see if they work correctly. If it passes that test then we run it against the new bg tables in btabs5yr to see if we can get improved data at the bg level. jgb, Jan, 2013. Resuming work after getting new bg base tables, late April, 2013. Run this job to generate acs2011.usbgupdates 5/2013. That dataset will be used in job tempusbgs to create "temporary" version of the us bg level profiles, enhanced with these new variable defns. Code will be added to the tempusbgs.sas setup to define the Pct variables that use EmployedCLF as the denominator. ---*; %let vintage=2011; %let period=5yr; %let vm4=%eval(&vintage - 4); %let years=&vm4._&vintage; %*let inset=stcnty; *<======================; %let inset=bgs; *<======================; %let outset=newbgvars; **libname basetbls "/pub/data/acs&vintage./basetbls"; libname btabs5yr "/pub/data/acs&vintage/btabs5yr" access=readonly; libname acs "/pub/data/acs&vintage."; libname user "/SAS_temp/userb"; %let ie=e; *<----variable naming convention being used: i for item or e for estimate. In btabs5yr we used e --; data merged&inset; *---We omit ustabs08 because there is no BG data from this dataset---; merge btabs5yr.us&inset.00_07 btabs5yr.us&inset.08 btabs5yr.us&inset.09_16 btabs5yr.us&inset.17_20 btabs5yr.us&inset.21_24 btabs5yr.us&inset.25_27; * acs.allgeos&years(in=ingeos rename=(logrecno=logrecnoCK)); by state logrecno; %macro filter; %if &inset=stcnty %then %str( where sumlev='040' and state='29'; ); %else %str( where sumlev='150'; ); %mend filter; %filter ; run; %macro pct(var); %global univar; if &univar then Pct&var=100*&var/&univar; *** format Pct&var 5.1; %mend pct; *---------Here is the conversion data step-------------*; data acs.&outset.5yr(label="New output with select updated variables"); length default=5 esriid $16 State $2 Logrecno 5; retain vintage "&vintage" period "&period"; set merged&inset (rename=(logrecno=logrecnoC)); Totpop=b01001&ie.1; TotHUs=b25002&ie.1; *--Add 2 new variables for the unweighted sample counts of perons and housing units--*; %let univar=totpop; Persons_Sampled=b00001&ie.1; %pct(Persons_Sampled) %let univar=TotHUs; HUs_Sampled=b00002&ie.1; %pct(HUs_Sampled) *--Indented vars are not new formulae--; Age0_4=b01001&ie.3 + b01001&ie.27; %let univar=totpop; Over5=TotPop - Age0_4; %pct(Over5) Under18= sum(of b01001&ie.3-b01001&ie.6 b01001&ie.27-b01001&ie.30); %pct(under18) Over18=Totpop - Under18; %pct(over18) Over65=sum(of b01001&ie.20-b01001&ie.25 b01001&ie.44-b01001&ie.49); %pct(over65) Males=b01001&ie.2; %let univar=Males; Over18males=Males - sum(of b01001&ie.3-b01001&ie.6); %pct(Over18Males) %let univar=Females; Females=b01001&ie.26; Over18females=Females - sum(of b01001&ie.27-b01001&ie.30); %pct(Over18Females) *---These poverty variables rely on table c17002 being available. My doc says it is but it is now occurring in the bg level base tables datasets or on ustabs17_205yr . Is it **only** available on the BG files???--; PovUniverse=c17002&ie.1; *<---See comment, above---; %let univar=PovUniverse; poor=c17002&ie.2 + c17002&ie.3; ; %pct(poor) PovRatioUnderHalf=c17002&ie.2; %pct(PovRatioUnderHalf) PovRatio1to2=sum(of c17002&ie.4-c17002&ie.7); %pct(PovRatio1to2) PovRatioOver2=c17002&ie.8; %pct(povratioOver2) Worker16=b08301&ie.1; %let univar=Worker16; Commuters=Worker16 - b08301&ie.21; *--subtract worked at home--; %pct(commuters) DriveAlone=b08301&ie.3; %pct(driveAlone) Carpooled=b08301&ie.4; %pct(carpooled) PublicTrans=b08301&ie.10; %pct(PublicTrans) WalkToWork=b08301&ie.19; %pct(WalkToWork) OtherCommute=sum(of b08301&ie.16 b08301&ie.17 b08301&ie.18 b08301&ie.20); %pct(OtherCommute) WorkAtHome=b08301&ie.21; %pct(workathome) if commuters then AvgCommute=b08135&ie.1/Commuters; *--NA for BGs--; format AvgCommute 5.1; EmployedCLF=c24010&ie.1; *---replace formula being used now referencing b23001---; *---Once we have EmployedCLF defined then we can define all the Pct variables that use it as denominator-; *----We have moved (copied) this code to the tempusbgs.sas setup since the numerators are not defined here.---; /* ========================begin comment==================================== 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 SelfEmpWorkders UnpaidFamWorkers; 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 PctSelfEmpWorkders PctUnpaidFamWorkers; if EmployedCLF then do _i=1 to dim(pcts); pcts{_i}=nums{_i}*100/EmployedCLF; end; ==========================end comment====================================== */ format pct: 5.1; Logrecno=input(logrecnoC,7.); **drop logrecnoC; Lastnewvar=.; *--to used in keep list below---; keep _character_ logrecno Persons_sampled--Lastnewvar; drop Lastnewvar; run; data two; set acs.&outset.5yr(obs=2); run; proc fsbrowse printall data=two; title "acs.&outset.5yr";