x cd /pub/data/acs2009/Tools; %let pgm=test_profiles_from_base; filename pgm "&pgm..sas"; *---program to test feasibility of extracting our mcdcprofiles data from basetbls (detailed, summary) tables. Can we find a formula that lets us derive the same values we are provided with via the Bureau profiles data sets? And can we derive useful moes for these derived items? ----; %let year=2009; libname acs20xx "/pub/data/acs&year "; libname basetbls "/pub/data/acs&year./basetbls" access=readonly; proc contents data=acs20xx.usmcdcprofiles noprint out=usmcdcprofilevars(keep=name type); run; proc sql noprint; select name into :moevars separated by ' ' from usmcdcprofilevars where index(name,'_moe'); select name into :keepvars separated by ' ' from usmcdcprofilevars where not (substr(name,1,3)='pct' or index(name,'_moe')); quit; %***put moevars=&moevars; data acs20xx.testprofiles(label="derived from basetbls data"); if 0 then set acs20xx.usmcdcprofiles(drop=pct: &moevars); *--to define the variables of interest with labels, formats, etc.--; merge basetbls.ustabs00_07 basetbls.ustabs08 basetbls.ustabs09_16 basetbls.ustabs17_20 basetbls.ustabs21_24 basetbls.ustabs25_27; by geoid; where geoid in ('01000US','04000US29','05000US29019'); DateCreated=Today(); Format DateCreated date7.; *--Table D1---; TotPop= B01001i1; Age0_4= B01001i3 + B01001i27; Age5_9= B01001i4 + B01001i28; Age10_14=B01001i5 + B01001i29; Age15_19=B01001i6 + B01001i7 + B01001i30 + B01001i31; Age20_24= sum(of B01001i8 - B01001i10 B01001i32 - B01001i34); age25_34= B01001i11 + B01001i12 + B01001i35 + B01001i36; age35_44= B01001i13 + B01001i14 + B01001i37 + B01001i38; age45_54= B01001i15 + B01001i16 + B01001i39 + B01001i40; age55_59= B01001i17 + B01001i41; age60_64= B01001i18 + B01001i19 + B01001i42 + B01001i43; age65_74= sum(of B01001i20 - B01001i22 B01001i44 - B01001i46); age75_84= B01001i23 + B01001i24 + B01001i47 + B01001i48; Over85= B01001i25 + B01001i49; MedianAge=B01002i1; Over5=TotPop - Age0_4; Over15=Totpop - sum(of Age0_4 Age5_9 Age10_14); Under18= sum(of age0_4--age10_14 B01001i6 B01001i30); Over18= TotPop - Under18; Over21= sum(of B01001i9-B01001i25 B01001i33-B01001i49); Over25= sum(of Age25_34 -- over85); Over62= sum(of B01001i19-B01001i25 B01001i43-B01001i49); Over65= sum(of age65_74--Over85); *--Table D2--; Males= B01001i2; Over18Males= sum(of B01001i7-B01001i25); Over65Males=sum(of B01001i20-B01001i25); Females=B01001i26; Over18Females=sum(of B01001i31-B01001i49); Over65Females=sum(of B01001i44-B01001i49); *---Table D3---*; OneRace=sum(of B02001i2-B02001i7); White1=B02001i2 ; Black1=B02001i3; Indian1=B02001i4; Asian1=B02001i5; HawnPI1=B02001i6; Other1=B02001i7; MultiRace=B02001i8; White2=B02008i1; Black2=B02009i1; Indian2=B02010i1; Asian2=B02011i1; HawnPI2=B02012i1; Other2=B02013i1; *--Table D4---; HispanicPop= B03002i12; NonHispPop=B03002i2; NonHispWhite=B03002i3; NonHispBlack=B03002i4; NonHispAmInd=B03002i5; NonHispAsian=B03002i6; NonHispHawnPI=B03002i7; *---Table E1---*; TotHHs=B19001i1; HHinc0 = B19001i2; HHinc10 = B19001i3; HHinc15 = B19001i4 + B19001i5; HHinc25 = B19001i6 + B19001i7; HHinc35 = sum(of B19001i8-B19001i10); HHinc50 = sum(of B19001i11-B19001i12); HHinc75 = B19001i13; HHinc100 = sum(of B19001i14-B19001i15); HHinc150 = B19001i16; HHinc200 = B19001i17; MedianHHInc=B19013i1; AvgHHInc=round(B19025i1/TotHHs); NumHHEarnings=B19051i2; if NumHHEarnings then AvgHHEarnings=round(B19061i1/NumHHEarnings); NumHHSocSec= B19055i2; if NumHHSocSec then AvgHHSocSec=round(B19065i1/NumHHSocSec); NumHHRetInc= B19059i2; if NumHHRetInc then AvgHHRetInc=round(B19069i1/NumHHRetInc); NumHHSuppSecInc= B19056i2; if NumHHSuppSecInc then AvgHHSuppSecInc=round(B19066i1/NumHHSuppSecInc); NumHHPubAssist= B19057i2; if NumHHPubAssist then AvgHHPubAssist=round(B19067i1/NumHHPubAssist); *--No food stamps data--; *----Table E2-----; FamHHs=B19101i1 ; FamHHInc0 = B19101i2; FamHHInc10 = B19101i3; FamHHInc15 = B19101i4 + B19101i5; FamHHInc25 = B19101i6 + B19101i7; FamHHInc35 = sum(of B19101i8-B19101i10); FamHHInc50 = sum(of B19101i11-B19101i12); FamHHInc75 = B19101i13; FamHHInc100 = sum(of B19101i14-B19101i15); FamHHInc150 = B19101i16; FamHHInc200 = B19101i17; MedianFamInc=B19113i1; if FamHHs then AvgFamInc=round(B19127i1/FamHHs); *---Table E3----; PCI= B19301i1; NonFamHHs=B11001i7; MedianNonFamInc=B19202i1; if nonfamhhs then AvgNonFamInc=round(B19214i1/NonFamHHs); * =========================== These counts not found... FulltimeWorkers= FullTimeWorkersMale= FilltimeWorkersFemale= ==========================end comment======================================; MedianEarnings=B20002i1; * ========================begin comment====================================; **MedianEarningsMale=B20002i2; *--these are for all workers but we needed full-time year-around workers--; **MedianEarningsFemale=B20002i3; PovUniverse=B17021i1; Poor= B17021i2; *---No poverty-by-age data---; _NonRelatives=sum(of B17021i6 B17021i10 B17021i13 B17021i23 B17021i27 B17021i30); _PoorNonRelatives= sum(of B17021i6 B17021i10 B17021i13 ); PovUniverseFamilyPop= B17021i3 + B17021i9 - _NonRelatives; *--This is named "FamilyPop[Poor]" or now but it should be CHANGED!-; poorInFamily= B17021i3 - _PoorNonRelatives; PovUniverseUnrelated= B17021i14 + B17021i31 + _NonRelatives; *---this is not producing numbers that match our profiles--; poorUnrelated= B17021i14 + _PoorNonRelatives; PovRatioUnderHalf= C17002i2; *** PovRatiov5tov75 and PovRatiov75to1 NA, but we could get the combination of the 2: PopRatio50to1 from table C17002 --; PovRatio1to2=sum(of C17002i4-C17002i7); *--povratioOver3 NA but we could get PovRatioOver2. MeanPovRatio NA. Could not get anything comparable--; *---Table E5---; *----None of this is available at BG level---; *--Table E6--; OwnKidsUnder6= B23008i2; OwnKidsU6AllPrntsWk=B23008i4; OwnKidsOver6=B23008i15; OwnKidsO6AllPrntsWk=B23008i17; *--Table E7---; Worker16=B08301i1; *Commuters= sum(of B08301i2 B08301i10 B08301i16-B08301i20); *--See below--; DriveAlone=B08301i3; Carpool=B08301i4; PublicTrans=B08301i10; WalkToWork=B08301i19; OtherCommute=sum(of B08301i16-B08301i18 B08301i20); WorkAtHome=B08301i2; Commuters=Worker16 - WorkAtHome; *--AvgCommute NA --; *---Table E8---; EmployedCLF= C24010i1; ManProfOccs=C24010i3 + C24010i40; ServiceOccs= C24010i18 + C24010i55; SalesOffOccs= C24010i26 + C24010i63; FarmFishOccs=C24010i29 + C24010i66; ConsOccs= C24010i30 + C24010i67; TransOccs=C24010i33 + C24010i70; *---Table E9---; Agriculture= C24030i3 + C24030i30; Construction=C24030i6 + C24030i33; Manufacturing=C24030i7 + C24030i34; WholesaleTrade=C24030i8 + C24030i35; RetailTrade=C24030i9 + C24030i36; Transportation=C24030i10 + C24030i37; Information=C24030i13 + C24030i40; Finance_Ins=C24030i14 + C24030i41; Professional=C24030i17 + C24030i44; Educ_Health_SocSvcs=C24030i21 + C24030i48; RecreationEtc=C24030i24 + C24030i51; OtherIndustries=C24030i27 + C24030i54; PublicAdmin=C24030i28 + C24030i55; *---Table E10---; PrivWageWorkers=B24080i3 + B24080i13; GovWorkers=sum(of B24080i7-B24080i9 B24080i17-B24080i19); SelfEmpWorkers=B24080i10 + B24080i20; UnpaidFamWorkers=B24080i11 + B24080i21; *---Table E11 : NA (not asked all 5 years)---; *---Table S1---; Families= B11001i2; FamsWithKids=sum(of B11003i3 B11003i10 B11003i16); MarriedCouples=B11003i2; CouplesWithKids=B11003i3; SingleMaleFamilies=sum(of B11005i6 B11005i15); SingleFathers=B11003i10; SingleFemaleFamilies=B11005i7 + B11005i16; SingleMothers=B11003i16; *NonFamHHs already defined-; LivingAlone= B11001i8; Over65Alone=B09017i14 + B09017i17; HHsWithKids=B11005i2 ; HHsWithElders=B11007i2; HHpop=B11002i1; *---goes with table S2 but we need it to calculate the avgsize var--; FamHHPop=B11002i2 ; label FamilyPop="Persons in families"; *<---Not the same as persons living in family hhs---; FamilyPop=sum(of B11002i4 B11002i7 B11002i10) ; *---We only count those who are family members, excluding non-relatives---; if TotHHs then AvgHHSize= HHpop/TotHHs; if families then AvgFamSize=FamilyPop/Families; *---Table S2----; *--first 3 vars already define elswhere: totpop, hhpop and famhhpop---; NonFamHHpop=B11002i12; LivingAlone=B11001i8; *--it is a HH count but in this case persons and HHs are the same number--; GrpQuarters=B09016i33; *---Table S3---; Householder= B09016i4 + B09016i20 ; Spouse=B09016i7; Child=B09016i8; OtherRelative=sum(of B09016i9-B09016i12); NonRelative=B09016i13 + B09016i27; UnmarriedPartner=B09016i16 + B09016i30; if TotHHs then UMPartnerHHsPerK=round(1000*UnmarriedPartner/TotHHs); *---Table S4---; Over15=B12001i1 ; Married=sum(of B12001i5 B12001i8 B12001i14 B12001i17); Separated=B12001i7 + B12001i16; Widowed=B12001i9 + B12001i18; Divorced=B12001i10 + B12001i19; *---Table S5 -- not available---; *---Talbe S6 -- not available---; *---Table S7---; Over3=B14002i1; EnrolledOver3=B14002i3 + B14002i27; InNursery=B14002i4 + B14002i28; InKindergarten=B14002i7 + B14002i31; InElementary=sum(of B14002i10 B14002i13 B14002i34 B14002i37); InHighSchool=B14002i16 + B14002i40; InCollege= sum(of B14002i19 B14002i22 B14002i43 B14002i46 ); *---Table S8---; Over25=B15002i1 ; LessThan9th=sum(of B15002i3-B15002i6 B15002i20-B15002i23); SomeHighSchool=sum(of B15002i7-B15002i10 B15002i24-B15002i27); HighSchool=B15002i11 + B15002i28; SomeCollege=sum(of B15002i12 B15002i13 B15002i29 B15002i30); Associates=B15002i14 + B15002i31; Bachelors=B15002i15 + B15002i32; GradProf=sum(of B15002i16-B15002i18 B15002i33-B15002i35); HighSchoolOrMore=HighSchool + SomeCollege + Associates + Bachelors + GradProf; Bachelorsormore=Bachelors + GradProf; *--Table S9---; Veteran=B21002i1; *--Unable to find table to derive ArmedForces or Civilian--; *--Table S10a. - no disability data yet--; *---Table S11---; Over1=sum(of C07201i1 C07202i1 C07203i1); SameHouse=sum(of C07201i2 C07202i2 C07203i2); DiffHouse=sum(of C07201i3 C07202i3 C07203i3); *---variables deailing with same state and county NA---; LivedAbroad= sum(of C07201i12 C07202i12 C07203i9); *---Tables S12, S13 and S14 NA--; *---Table S15---; ***Over5= B16004i1; *<---already defined above---; EnglishOnly=sum(of B16004i3 B16004i25 B16004i47); OthLang = Over5 - EnglishOnly; OthLangEnglishLTD= sum(of B16004i6 B16004i7 B16004i8 B16004i28 B16004i29 B16004i30 B16004i50 B16004i51 B16004i52 B16004i11 B16004i12 B16004i13 B16004i33 B16004i34 B16004i35 B16004i55 B16004i56 B16004i57 B16004i16 B16004i17 B16004i18 B16004i38 B16004i39 B16004i40 B16004i60 B16004i61 B16004i62 B16004i21 B16004i22 B16004i23 B16004i43 B16004i44 B16004i45 B16004i65 B16004i66 B16004i67); Spanish= sum(of B16004i4 B16004i26 B16004i48); SpanishEnglishLTD=sum(of B16004i6-B16004i8 B16004i28-B16004i30 B16004i50-B16004i52); *---Table H1---; TotHUs=B25002i1 ; OccHUs=B25002i2; OwnerOcc=B25003i2; RenterOcc=B25003i3; if OwnerOcc then AvgOwnerHHSize=B25008i2/OwnerOcc; PersonsInRenterUnits=B25008i3; if RenterOcc then AvgRenterHHSize=PersonsInRenterUnits/RenterOcc; VacHUs=B25002i3; VacantForSale=B25004i4; VacantForRent=B25004i2; VacantSeasonal=B25004i6; TotalOwnerUnits=OwnerOcc + VacantForSale; if TotalOwnerUnits then OwnerVacRate=100*VacantForSale/TotalOwnerUnits; TotalRentalUnits=RenterOcc + VacantForRent; if totalrentalunits then RenterVacRate=100*VacantForRent/TotalRentalUnits; PersonsInOwnerUnits=B25008i2; *---Table H2---; Units1=B25024i2 + B25024i3; Units1Detached=B25024i2; Units1Attached=B25024i3; Units2=B25024i4; Units3_4=B25024i5; Units5_9=B25024i6; Units10_19=B25024i7; Units20up=B25024i8 + B25024i9; MobileHomes=B25024i10; BoatRV=B25024i11; if TotHUs then MobileHomesPerK=round(1000*MobileHomes/TotHUs); *---Table H3---; Built2005orLater=B25034i2 ; Built2000_2004=B25034i3; Built1990_1999=B25034i4; Built1980_1989=B25034i5; Built1970_1979=B25034i6; Built1960_1969=B25034i7; Built1950_1959=B25034i8; Built1940_1949=B25034i9; BuiltBefore1940=B25034i10; *---Table H4---; MovedIn2005orLater= B25038i3 + B25038i10; MovedIn2000_2004 = B25038i4 + B25038i11; MovedIn1990_1999 = B25038i5 + B25038i12; MovedIn1980_1989 = B25038i6 + B25038i13; MovedIn1970_1979 = B25038i7 + B25038i14; MovedInBefore1969 = B25038i8 + B25038i15; *---Table H5---; NoVehicles=B25044i3 + B25044i10; Vehicles1 =B25044i4 + B25044i11; Vehicles2 =B25044i5 + B25044i12; VehiclesGE3 =sum(of B25044i6-B25044i8 B25044i13-B25044i15); *---Table H6---; HHFUtilGas=B25040i2; HHFLPGas= B25040i3; HHFElectric= B25040i4 ; HHFKerosene= B25040i5 ; HHFCoal=B25040i6; HHFWood= B25040i7; HHFSolar=B25040i8; HHFOther= B25040i9; HHFNoFuel=B25040i10; *---Table H7---; NoPlumbing=B25049i4 + B25049i7; NoKitchen=B25053i4 + B25053i7; NoPhone= B25043i7 + B25043i16; *---Table H8---; PersonsPerRoomLow=sum (of B25014i3 B25014i4 B25014i9 B25014i10); PersonsPerRoomMedium=B25014i5 + B25014i11; PersonsPerRoomHigh=sum (of B25014i6 B25014i7 B25014i12 B25014i13); *---Table H9---; HvalUnder50=sum(of B25075i2-B25075i9); Hval50= sum(of B25075i10-B25075i14); Hval100=B25075i15 + B25075i16; Hval150=B25075i17 + B25075i18; Hval200=B25075i19 + B25075i20; Hval300=B25075i21 + B25075i22; Hval500=B25075i23 + B25075i24; HvalOverMillion=B25075i25; MedianHValue=B25077i1; if OwnerOcc then AvgHValue=round(B25079i1/OwnerOcc); *---Table H10---; HUsMort=B25087i2; HUsMortOver30Pct=sum(of B25091i8-B25091i11); MedianOwnerCostsMort=B25088i2 ; HUsNoMort= B25087i18; HUsNoMortOver30Pct=sum(of B25091i19-B25091i22); MedianOwnerCostsNoMort=B25088i3 ; *---Table H11---; CashRenter=B25054i1 ; NoCashRenter=B25056i24 ; MedianGrossRent=B25064i1; if cashrenter then AvgGrossRent= round(B25066i1/cashrenter); *<===denominator should NOT be RenterOcc!!---; CashRenterOver30Pct= sum(of B25070i7-B25070i10); CashRenterOver750 =sum(of B25063i17-B25063i23); *---for some reason the keep stmt with double-dash did not work (we got all the base tables varsiables)--; *keep geoid name totpop -- cashRentover750; *<=======; keep &keepvars; run; ods html file="&pgm..html"; proc print data=_last_; format areaname $32.; run; ods html close; ods html file="&pgm._compare.html"; *---use proc compare to generate report showing differences between what we get using these formulae vs what we have on our usmcdctrends data set.---; data compare; set acs20xx.usmcdcprofiles(keep=geoid &keepvars); where geoid in ('01000US','04000US29','05000US29019'); run; proc compare data=acs20xx.testprofiles(firstobs=2) compare=compare(firstobs=2); title "&pgm.: Comparing Our Derived Values with Those on the usmcdctrends Set"; run; ods html close;