x cd /pub/data/pl942000/Tools; %let pgm=pl94agg_sumlev155; filename pgm "&pgm..sas"; *******Although we did not know it at the time (because it was not included on an earlier SLSC for pl94) there were already 155 summary levels on pl942000. However, these did NOT include 99999 non-place-remainder-of-county summaries, which are important for Daryl Hobbs and others. So this was not a total waste of time. Creation of the pl942000.mosl155 data set was NOT done here, but rather in setup pl94agg.sas in the same lib. *******; /*---generate place-within-county summaries (SUMLEV code 155) by aggregating level 740 data--; John Blodgett, OSEDA, U. of Missouri Outreach & Extension 4-04-01. ---*/ %libname(pl942000,opts=); libname user '/tmp/scratch/user'; options msglevel=i; options ls=132 ps=60 nodate; title 'Conversion of pl94-171 Data to Create Summary Level 155 (Place Within County) Summaries'; title2 'Test Run Using South Dakota and creating pl9490.sdsl155 Data set'; *-------------------Select the 740 level data to be aggregated--------------------*; /*<=========================Comment out===================================== proc sort data= pl942000.sdsums( where =(sumlev in ('740','160') and pop100)) out=aggin(keep= _numeric_ sumlev county placeFP placeCC msacmsa pmsa state areaname); by placefp county ; run; ===========================End commented out================================ */ /*<=========================Comment out===================================== data aggin; set pl942000.sdsums; ***fails with msg complaining about sort order of sdgeos in view **( where =(sumlev in ('740','160') )); if sumlev in ('740','160'); if pop100; keep _numeric_ sumlev county placeFP placeCC msacmsa pmsa state areaname; run; proc sort; by placefp county ; run; ===========================End commented out================================ */ %agg(aggin=aggin,aggout=aggout, 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; data pl942000.sdsl155(label='Summary Level 155 for SD'); set aggout; by placefp county; if first.placefp then do; *--this should be the level 160 place-total summary--; if sumlev ne '160' and placefp ne '99999' 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'; format county $county24.; run; proc sort data=pl942000.sdsl155; by county placefp; run; proc print data=pl942000.sdsl155(obs=50); by county; id placefp areaname; run; %include sascode(notify);