x cd /pub/data/pl942000/Tools; %let pgm=pl94agg; filename pgm "&pgm..sas"; /*---Aggregate the standard pl94 data to get new summary levels. In this run we create: mobgs150 -- complete bg summaries moplc155 -- place within county summaries incl. 99999 remainders. Repeat these for il and ks. John Blodgett, OSEDA, U. of Missouri Outreach & Extension 4-06-01. Rerunning 4-24-01 to fix bug that was causing us to lose the 99999-remainder of the first county in the state. ---*/ libname pl942000 '/pub/data/census_2000/pl942000'; libname user '/SAS_temp/user'; options msglevel=i; options ls=132 ps=60 nodate; title 'Conversion of pl94-171 Data to Create Summary Levels 150 (Complete Block Group) and 155 Summaries'; %macro doit(state,stab,step1=1); *-------------------Select the data to be aggregated--------------------*; %if &step1 %then %do; data aggin&stab; set pl942000.&stab.sums; where sumlev in ('740','160'); if pop100; keep _numeric_ sumlev county placeFP placeCC msacmsa pmsa state areaname tract bg; drop geo_id; run; proc sort; by placefp county ; run; *-------------------Create the Place-within-county (sl155) summaries------------------------*; %agg(aggin=aggin&stab,aggout=aggout&stab, aggvars=totpop--mrovr18 landsqmi areasqmi intptlon intptlat, means=intptlon intptlat,mweights=totpop,agglvl=1,dropvars=_lvl_ _nag_, aggby=placefp county,idvars=areaname msacmsa pmsa placeCC sumlev) run; %end; data pl942000.&stab.sl155(label="Level 155 (place within county) sums - &stab"); length sumlev $3 geocode $11; retain areaname county placefp placecc msacmsa pmsa; set aggout&stab; by placefp county; if first.placefp and placefp ne '99999' then do; *--this should be the level 160 place-total summary--; if sumlev ne '160' then do; error '****Logic Problem -- expecting a level 160 Summary**** '; abort; end; _totpop=totpop; retain _totpop; drop _totpop; placename=areaname; retain placename; drop placename; delete; *--delete the complete-place summary, just used to pick up name and total pop-; end; *--it is not first obs with the placefp so it should be a place within county obs--; if sumlev ne '740' then do; error '****Logic Problem -- expecting a level 740 Summary**** '; abort; end; if placefp='99999' then areaname='Remainder (non-place portion) of county'; else do; areaname=placename; if totpop ne _totpop then areaname=trim(areaname)|| ' (pt)'; end; sumlev='155'; geocode=county||'-'||placefp; format county $county24.; run; proc sort data=pl942000.&stab.sl155; by county placefp; run; proc print data=pl942000.&stab.sl155(obs=50); by county; id placefp areaname; title2 "Partial Listing of pl942000.&stab.sl155"; run; *---------------Now do complete block groups (level 150)-------------------------------------*; proc sort data=aggin&stab(where=(sumlev='740') drop=placefp placecc areaname) out=aggin2; by county tract bg; run; %agg(aggin=aggin2,aggout=aggout2, aggvars=totpop--mrovr18 landsqmi areasqmi intptlon intptlat, means=intptlon intptlat,mweights=totpop,agglvl=1,dropvars=_lvl_ _nag_, aggby=county tract bg,idvars=msacmsa pmsa) run; data pl942000.&stab.bgs150(label="Complete BG summaries for &stab"); retain sumlev '150'; length geocode $16 esriid $12; retain county tract bg msacmsa pmsa; *--to make them go 1st in pdv--; set aggout2; geocode=county||'-'||tract||'-'||bg; esriid=compress(geocode,'-.'); run; proc print data=pl942000.&stab.bgs150(obs=50); by county; id tract bg; title2 "Partial Listing of pl942000.&stab.bgs150"; run; %mend doit; options nomprint; %dostates(17 20 29);