x cd /pub/data/popests/Tools; %let pgm=ussccnvt20YY; filename pgm "&pgm..sas"; *---Convert US Sub-county (place, et al) population estimates -- time series, 2010-20YY [YY=&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, 2012. JGB, May, 2013. JGB, May, 2014. JGB, May, 2015. JGB, May, 2016. JGB, May, 2017. ---*; %let temp=; *<--set to null when embargo ends---; %let revised=%str(); %let maxobs=99999999; %let year=2016; %let yr=%substr(&year,3,2); %let funcstat=funcstat; *---starting with 2013 vintage. Prior to that it was not on the file.---; %let primgeo=primgeo; *--starting with 2014 vintage there is a Primitive Geography Flag var----; libname popests "/pub/data/popests/&temp"; libname corrlst '/pub/data/corrlst' access=readonly; *** filename csvin "/pub/data/popests/rawdata/sub-est&year.-all.csv"; *<===This worked for 2011. lowcase plus no "_"===; *---in 2013 raw data as downloaded came 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. ---; *---in 2015 (vintage 2014) the data came as a single CSV file ---; *---in 2017 (vintage 2016) the data came as a single CSV file ---; filename csvin "/pub/data/popests/rawdata/SUB-EST&year._ALL.csv"; *<===check to see the name each year==; * ==== *; title "&pgm: Convert 2010-&year Census Bureau Sub-County level Population Estimates"; %macro poplist; %do i=10 %to &yr %by 1; PopJL&i %end; %mend poplist; %macro poplistr; %do i=&yr %to 10 %by -1; PopJL&i %end; %mend poplistr; data popests.ussc&yr(label="US subcounty pop estimates 2010 thru &year &revised") popests.mosc&yr(label="Missouri subcounty pop estimates 2010 thru &year &revised"); infile csvin dsd firstobs=2 obs=&maxobs missover lrecl=1024 termstr=crlf ; *** termstr=crlf ; missing Z X; *<---Bureau was 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).--; missing A Z X; *---places that were not around in 2010 get a value of A for pop010c; length SumLev $3 State Stab $2 Geocode $17 cnty $3 mcd placefp Fipco County $5 Areaname $40 Concit $5 Funcstat $1 primgeo $1; format county $county.; length Popest PopChang PctChang PopCh1yr PctCh1yr 5; length %poplistr popestBase pop10c 5; label Popest="Current Estimate (7-&year)" PopChang='Pop Change Since 2010 Census' PctChang='% Change Since 2010 Census' PopCh1yr='Pop Change Latest Yr' PctCh1yr='% Change Latest Yr'; format PctChang PctCh1yr 5.1; length _statename $40; input SumLev State Cnty Placefp MCD Concit &primgeo &funcstat Areaname _statename pop10c 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); when ('172') geocode=%concatd(state,concit,placefp); end; label placefp='FIPS place code' popestBase='Estimates base' pop10c='Unadjusted 2010 census Pop' ; label primgeo="Primitive Geography Flag" funcstat="Functional Status"; %macro poplbls; %do i=10 %to &yr %by 1; PopJL&i="Pop Est 7-1-&i" %end; %mend poplbls; label %poplbls ; _curest=popjl&yr; *<==============================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 pop10c 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 2010 census. ---; PopChang=Popest - PopestBase; if Popestbase then PctChang=100*PopChang/popestbase; %let yrm1=%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; /* ========================begin comment==================================== 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; ==========================end comment====================================== */ ***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 sum 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 State; quit;