x cd /pub/data/popests/Tools; %let pgm=ussccnvt09; filename pgm "&pgm..sas"; *---Convert US Sub-county (place, et al) population estimates -- time series, 2000-2009 [&year]. Store results as a single SAS dataset - popests.ussc&yr, with mosc&yr subset. *************** ******* John Blodgett, OSEDA, UM Outreach and extension. Under contract with the Missouri Census Data Center JGB, June, 2010. And a rerun with revised input data, 9-9-10 ---*; %let temp=; *<--set to null when embargo ends---; %let revised=%str(rev.); %let maxobs=999999; %let year=2009; %let yr=%substr(&year,3,2); libname popests "/pub/data/popests/&temp"; libname corrlst '/pub/data/corrlst' access=readonly; *---raw data as downloaded comes in 2 files: an AL to MO file and a MT to WY file. We concatenated the 2 using UE and saved the results (with header line removed from 2nd file after appending) to the file used here in rawdata. ---; filename csvin "/pub/data/popests/rawdata/sub-est&year.-all.csv"; *<===check to see the name each year==; title "&pgm: Convert 2000-&year Census Bureau Sub-County level Population Estimates"; %macro poplist; %do i=0 %to &yr %by 1; PopJL0&i %end; %mend poplist; %macro poplistr; %do i=&yr %to 0 %by -1; PopJL0&i %end; %mend poplistr; data popests.ussc&yr(label="US subcounty pop estimates 2000 thru &year &revised") popests.mosc&yr(label="Missouri subcounty pop estimates 2000 thru &year &revised"); infile csvin dsd firstobs=2 obs=&maxobs missover lrecl=1024 termstr=crlf ; missing Z X; *<---Bureau now using X codes for the 2000 census pop when place was not there in 2000. 4 cities in Miss have the Z code indicating no reliable data (because of hurricane Katrina).--; length SumLev $3 State Stab $2 Geocode $17 cnty $3 mcd placefp Fipco County $5 Areaname $40; format county $county.; length Popest PopChang PctChang PopCh1yr PctCh1yr 5; length %poplistr popestBase pop00c 5; label Popest="Current Estimate (7-&year)" PopChang='Pop Change Since 2000 Census' PctChang='% Change Since 2K Census' PopCh1yr='Pop Change Latest Yr' PctCh1yr='% Change Latest Yr'; format PctChang PctCh1yr 5.1; *nput SumLev Areaname State Cnty Placefp MCD %poplist pop00c popestBase ; *length _statename _cntyname _plcname _mcdname $64; *--File layout doc indicated there would be separate input fields providing names of all these but the data did not correspond to the doc.---; length _statename $40; input SumLev State Cnty Placefp MCD Areaname _statename pop00c popestBase %poplist ; if state='00' then state=' '; if cnty='000' then cnty=' '; if mcd='00000' then mcd=' '; if placefp='00000' then placefp=' '; if cnty ne ' ' then county=state||cnty; fipco=county; if state ne ' ' then stab=put(state,$fipstab2.); *---Assign value of geocode------; select (SumLev); when ('040') do; geocode=state; Areaname=put(state,$state.); end; when ('050') do; geocode=county; end; when ('061') do; geocode=%concatd(county,mcd); end; when ('071') geocode=%concatd(county,mcd,placefp); when ('157') geocode=%concatd(county,placefp); when ('162') geocode=%concatd(state,placefp); when ('170','172') if placefp ne ' ' then geocode=%concatd(state,placefp); end; label placefp='FIPS place code' popestBase='Estimates base' pop00c='Unadjusted 2000 census Pop' ; %macro poplbls; %do i=5 %to &yr %by 1; PopJL0&i="Pop Est 7-1-0&i" %end; %mend poplbls; label PopJL00='Pop Est 7-1-00' PopJL01='Pop Est 7-1-01' PopJL02='Pop Est 7-1-02' PopJL03='Pop Est 7-1-03' PopJL04='Pop Est 7-1-04' %poplbls ; _curest=popjl&yr; *---No word yet (per Bureau web site) that StL has successfully challenged the new 08 estimate yet-----------(6-27-09)--; *<==============================Challenged pop overrides=========================================; if (sumlev='050' and county='29510') or (sumlev='162' and geocode='29-65000') then popjl06=353837 ; *--St. Louis city which is also a county equivalent----------------------; if popjl&yr ne _curest then Original_estimate=_curest; label original_estimate='Original estimate if successfully challenged'; Popest=PopJL&yr; *---We originally used pop00c as the base figure to calculate change and pct change. But to be consistent with the spreadsheets put out by Ryan and the Bureau we changed it to popestbase. This means that where we have had a change in the geographic defn of a place we now get comparisons based on the current geography. So if a town grew by 2000 by annexing that will not show up as growth if most of those 2000 people were already living there at the time of the 2000 census. ---; PopChang=Popest - PopestBase; if Popestbase then PctChang=100*PopChang/popestbase; %let yrm1=0%eval(&yr - 1); PopCh1yr=PopJL&yr - PopJL&yrm1; if PopJL&yrm1 then PCtCh1yr=PopCh1yr*100/popjl&yrm1; output popests.ussc&yr; if state='29' then output popests.mosc&yr; drop _:; run; proc print data=popests.ussc&yr(where=(original_estimate) keep=sumlev geocode areaname original_estimate popest); title2 'Cases Where Original Estimate Has Been Adjusted Per Successful Challenge'; run; ***x chmod 600 /pub/data/popests/ussc&yr..sas7bdat; *<--not publicly readable yet-------; ***x chmod 600 /pub/data/popests/mosc&yr..sas7bdat; *<--not publicly readable yet-------; proc means data=popests.mosc&yr n mean; class sumlev var popjl&yr; run; proc freq data=popests.ussc&yr(keep=sumlev state); tables SumLev state /missing; run; proc contents data=popests.ussc&yr position; title3 "Contents of popests.ussc&yr"; run; proc print data=popests.ussc&yr(obs=35); by state stab; title3 "First 25 Obs on popests.ussc&yr"; run cancel; proc datasets library=popests nolist; modify ussc&yr; index create SumLev; index create State; quit;