x cd /pub/data/popests/Tools; %let pgm=estimate_challenges; filename pgm "&pgm..sas"; /*-------Beginning with the vintage 2007 challenges we capture the data from the Bureau web page (http://www.census.gov/popest/archives/2000s/vintage_2007/07s_challenges.html) to create a corresponding SAS data set. Hardest and most important part is to attach SumLev and geographic codes to allow easy linkage to the estimates. John Blodgett, OSEDA, Under contract with the Missouri Census Data Center ------*/ libname popests '/pub/data/popests'; *filename in '/pub/data/popests/2007_challenges.txt'; *<=====================downloaded from web page, see above===; filename in '/pub/data/popests/2008_challenges.txt'; *<=====================downloaded from web page, see above===; %let year=2009; %let yearm1=%eval(&year-1); %let yr=%substr(&year,3,2); %let yrm1=%substr(&yearm1,3,2); %let yearm2=%eval(&year-2); %let yrm2=%substr(&yearm2,3,2); data challenges; infile in firstobs=4; input ; length _line $200 _linein $200; _linein=_infile_; _line=_infile_; length SumLev $3 Stab $2 Areaname $40 Original_estimate Revised_estimate 5; length challenge_accept_date $10; revised_estimate=compress(scan(_line,-1,' '),', '); %chopwrd(_line,dlms=%str( )) original_estimate=compress(scan(_line,-1,' '),', '); %chopwrd(_line,dlms=%str( )) challenge_accept_date=scan(_line,-1,' '); %chopwrd(_line,dlms=%str( )) stab=scan(_line,-1,' '); %chopwrd(_line,dlms=%str( )) Areaname=left(_line); length _gword $16; _gword=lowcase(scan(_line,-1,' ')); select(_gword); when ('city') sumlev='162'; when ('county','parish') sumlev='050'; when ('town','township') sumlev='061'; otherwise do; put _gword ' -- not recognzied as geographic type word *** '; delete; end; end; ***if _n_ le 2 then put / _all_; drop _: ; run; proc sort data=challenges; by stab sumlev areaname; run; data estcodes; set popests.ussc&yr(keep=_char_ popJL&yr PopJL&yrm1); proc sort; by stab sumlev areaname; run; data popests.challenges&yearm1(label="Successful challenges of vintage &yearm1 estimates"); merge estcodes(in=inests) challenges(in=inch); by stab sumlev areaname; if inch; if inch and stab='OH' and areaname=:'Sycamore township' then do; if fipco='39175' then delete; *--There are 2 matches on the name; end; else if not (first.areaname and last.areaname) then do; put '***********Caution: We have duplicate matches on key variables Stab, Sumlev and Areaname. May require a manual override ' 'to delete the extra observations that should not be matches.' / _all_; end; if not inests then do; put "***challenge obs not matched on estimates*** " stab= sumlev= areaname=; delete; end; Adjustment= Revised_estimate - Original_estimate; AdjustmentUsed= (revised_estimate=popjl&yrm1); EstPotentialRevised = popjl&yr + Adjustment; run; options ls=155; proc print data=popests.challenges&yearm1 ( drop=geocode state cnty mcd placefp fipco) label split="/"; title "popests.challenges&yearm1"; title2 "Most Geocodes Not Shown in this Report"; label challenge_accept_date='Challenge/Accept/Date' popjl&yr="New Latest/Estimate/(&year)" popjl&yrm1="Est for &yearm1/Released/This Yr" AdjustmentUsed="Adjsmt/Used in/New Estimates?"; id stab sumlev county areaname; format county $5.; run;