x cd /pub/data/acs2014/Tools; %let pgm=newbgvars; filename pgm "&pgm..sas"; *---Create new BG variables with new formulae for deriving variables from the base tables datasets at BG level. Run this job to generate acs.usbgupdates 12/2014. This data set used to update our final acs.usbgs data set in job usbgprofiles. At some point it would be better to use these formulae at the initial convert stage. NOTE that we make no attempt to capture the corresponding MOE variables for these newly defined vars. ---*; %let vintage=2014; %let period=5yr; %let vm4=%eval(&vintage - 4); %let years=&vm4._&vintage; *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 ei=i; *<----variable naming convention being used: i for item or e for estimate. In 2012 forward we use i. --; ****We do not reference any table vars on this set so we omit from following merge: btabs5yr.usbgs08 --*; data mergedbgs; merge btabs5yr.usbgs00_07 btabs5yr.usbgs09_16 btabs5yr.usbgs17_20 btabs5yr.usbgs21_24 btabs5yr.usbgs25_27; by state logrecno; where sumlev='150'; *--just to be certain--; run; %macro pct(var); %global univar; if &univar then Pct&var=100*&var/&univar; %mend pct; *---------Here is the conversion data step-------------*; data acs.newbgvars5yr(label="New data at BG level using alternate formulae"); length default=5 esriid $16 State $2 Logrecno 5; retain vintage "&vintage" period "&period"; set mergedbgs (rename=(logrecno=logrecnoC)); Totpop=b01001&ei.1; TotHUs=b25002&ei.1; *--Add 2 new variables for the unweighted sample counts of perons and housing units--*; %let univar=totpop; Persons_Sampled=b00001&ei.1; %pct(Persons_Sampled) %let univar=TotHUs; HUs_Sampled=b00002&ei.1; %pct(HUs_Sampled) *--Indented vars are not new formulae--; Age0_4=b01001&ei.3 + b01001&ei.27; %let univar=totpop; Over5=TotPop - Age0_4; %pct(Over5) ** Under18= sum(of b01001&ei.3-b01001&ei.6 b01001&ei.27-b01001&ei.30); %**pct(under18); ** Over18=Totpop - Under18; %**pct(over18); ** Over65=sum(of b01001&ei.20-b01001&ei.25 b01001&ei.44-b01001&ei.49); %**pct(over65); Males=b01001&ei.2; %let univar=Males; Over18males=Males - sum(of b01001&ei.3-b01001&ei.6); %pct(Over18Males) %let univar=Females; Females=b01001&ei.26; Over18females=Females - sum(of b01001&ei.27-b01001&ei.30); %pct(Over18Females); *---These poverty variables rely on table c17002 being available. -; PovUniverse=c17002&ei.1; *<---See comment, above---; %let univar=PovUniverse; poor=c17002&ei.2 + c17002&ei.3; ; %pct(poor) PovRatioUnderHalf=c17002&ei.2; %pct(PovRatioUnderHalf) PovRatiov5tov99=c17002&ei.3; %pct(PovRatiov5tov99); *--added 5-1-14, jgb---; PovRatio1to2=sum(of c17002&ei.4-c17002&ei.7); %pct(PovRatio1to2) PovRatioOver2=c17002&ei.8; %pct(povratioOver2) EmployedCLF=c24010&ei.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====================================== */ *--next 6 lines added 5-1-14--; Under18= B01001i3 + B01001i4 + B01001i5 + B01001i6 + B01001i27 + B01001i28 + B01001i29 + B01001i30; Over18= TotPop-Under18; Civilian=B21001i1; drop Under18 Over18 Civilian; ArmedForces=Over18 - Civilian; label Civilian='Perons over 18 not in military' ArmedForces='Persons Over 18 in Armed Forces'; if civilian then PctArmedForces=100*ArmedForces/Civilian; if over18 then PctCivilian=100*Civilian/Over18; format pct: 5.1; Logrecno=input(logrecnoC,7.); **drop logrecnoC; Lastnewvar=.; *--to be used in keep list below---; keep _character_ logrecno Persons_sampled--Lastnewvar; drop Lastnewvar; run; data two; set acs.newbgvars5yr(obs=2); run; proc fsbrowse printall data=two; title "acs.newbgvars5yr";