x cd /pub/data/popests/Tools; %let pgm=ussccnvt; filename pgm "&pgm..sas"; *---Convert US Sub-county (place, et al) population estimates -- time series, 2000-2002 [&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, July, 2003. ---*; %let maxobs=999999; %let year=2002; %let yr=%substr(&year,3,2); libname popests '/pub/data/popests'; libname corrlst '/pub/data/corrlst' access=readonly; filename csvin "/pub/data/popests/hup&year.C.txt"; *<===check to see the name each year==; title "&pgm: Convert 2000-&year Census Bureau Sub-County level Population Estimates"; %macro poplist; %do i=&yr %to 0 %by -1; PopJL0&i %end; %mend poplist; data popests.ussc&yr(label="US subcounty pop estimates 2000 thru &year") popests.mosc&yr(label="Missouri subcounty pop estimates 2000 thru &year"); infile csvin dsd firstobs=2 obs=&maxobs missover lrecl=1024; length SumLev $3 State Stab $2 Geocode $17 cnty $3 mcd placefp County $5 Areaname $40; length %poplist popestBase pop00c 5; length Popest PopChang PctChang PopCh1yr PctCh1yr 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; input SumLev State Cnty MCD Placefp Areaname %poplist popestBase pop00c ; 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; if state ne ' ' then stab=put(state,$fipstab2.); *---Assign value of geocode------; select (SumLev); when ('010') geocode=' '; *--us totals--; when ('020') do; _NREG+1; geocode=put(_nreg,1.); end; when ('030') do; _NDIV+1; geocode=put(_ndiv,1.); end; when ('040') geocode=state; when ('050') geocode=county; when ('061') geocode=%concatd(county,mcd); when ('071') geocode=%concatd(county,mcd,placefp); when ('157') geocode=%concatd(county,placefp); when ('162') geocode=%concatd(state,placefp); when ('170','172') geocode=' '; *<---no concit code provided---; end; label placefp='FIPS place code' popestBase='Estimates base' pop00c='Unadjusted 2000 census Pop' PopJL00='Pop Est 7-1-00' PopJL01='Pop Est 7-1-01' PopJL02='Pop Est 7-1-02' ; *----uncomment these as years are added----; *** Label PopJL03='Pop Est 7-1-03'; *** Label PopJL04='Pop Est 7-1-04'; *** Label PopJL05='Pop Est 7-1-05'; *** Label PopJL06='Pop Est 7-1-06'; *** Label PopJL07='Pop Est 7-1-07'; *** Label PopJL08='Pop Est 7-1-08'; *** Label PopJL09='Pop Est 7-1-09'; 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=188*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; ** 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 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; proc datasets library=popests nolist; modify ussc&yr; index create SumLev; index create State; quit;