x cd /pub/data/sf12000x/Tools; %let pgm=cnvt_sf12000x_moschls; filename pgm "&pgm..sas"; *----Specific occurrence of general convert routine. Run just for Missouri School Districts, both complete and within-county. John Blodgett, OSEDA, Initial coding July 16, 2001. Rerunning 7.28.01 after finding bug in aggregating of the pct sets used as input. We are also now creating a moschlcos data set with data for districts within counties. ----*; title 'Convert Mo School District SF1 Data to SF1X Extract'; libname sf12000 '/pub/data/census_2000/sf12000' access=readonly; libname sf12000x '/pub/data/sf12000x'; libname pl9490tx '/pub/data/pl9490/pl9490tx'; libname user '/tmp/storage/john'; *<==================; /*<=========================Comment out===================================== *---------------Part 1: Complete Districts------------------------------------*; data _2000s; length default=5; length esriid $42.; merge sf1.moschlsph sf1.moschlspct; by geocode; %include sascode(sf12000x.sas); keep sumlev geocode desedist ncescode areaname areasqmi intptlon intptlat esriid; *--in addtion to totpop etc.--; run; proc sort data=_2000s; by desedist; run; data sf1x.moschls(label='Mo School Districts'); merge _2000s (in=in2k) pl9490tx.moschl00(in=in90 keep=desedist geocode areaname totpop rename=(totpop=totpop90)); by desedist; if in2k; change=totpop - totpop90; if totpop90 then pctchange=100*change/totpop90; run; proc print data=sf1x.moschls(obs=50); var _char_ totpop totpop90 change pctchange; title2 'Selected Vars from sf1x.moschls'; run; ===========================End commented out================================ */ /*<=========================Comment out===================================== *--------------------Part 2: Districts Within Counties-------------------------------*; proc sort data=sf1.mogeos(where=(sumlev='101') keep=sumlev geocode county sdelm sduni ) out=moblks; by geocode; run; *--We begin by doing a special aggregation to get the 90 pop counts for these split districts. We did not have a moschlcos data set in pl9490tx. Here we create a baby set there--; data blkpops_withdist; merge pl9490tx.moblks00(keep=geocode totpop where=(totpop > 0) in=indata ) moblks(in=ingeos); by geocode; if ingeos and indata; length ncescode $5; ncescode=sduni; sumlev='su2'; output; ncescode=sdelm; sumlev='se2'; output; keep county ncescode sumlev totpop; run; proc sort; by sumlev ncescode county; run; %agg(aggin=blkpops_withdist,aggout=aggout, aggby=sumlev ncescode county, aggvars=totpop, agglvls=1, dropvars=_lvl_ _nag_) run; data pl9490tx.moschlcopops(label='Total 90 Pop (only) for Districts within Cos'); length desedist $6 ; set aggout; by sumlev ncescode; if first.ncescode then desedist=put(ncescode,$schcnvt6.); retain desedist; keep desedist sumlev totpop county ncescode; run; proc sort; by desedist county; run; proc print data=pl9490tx.moschlcopops(obs=50); title2 'Partial Listing of pl9490tx.moschlcopops'; run; *--and now, we can proceed to creating the sf12000x set for moschlcos-; data _2000s2; length default=5; length esriid $42.; merge sf1.moschlcosph sf1.moschlcospct; by geocode; %include sascode(sf12000x.sas); keep sumlev geocode desedist ncescode areaname county partflag areasqmi intptlon intptlat esriid; *--in addtion to totpop etc.--; run; proc sort data=_2000s2; by desedist county; run; ===========================End commented out================================ */ data sf1x.moschlcos(label='Mo School Districts within Counties'); merge _2000s2 (in=in2k) pl9490tx.moschlcopops(in=in90 keep=desedist county totpop rename=(totpop=totpop90)); by desedist county; if not in90 then do; _no90+1; if _no90 <= 50 then do; put desedist= county= ; delete; end; else stop; end; if in2k; change=totpop - totpop90; if totpop90 then pctchange=100*change/totpop90; run; proc print data=sf1x.moschlcos(obs=50); var _char_ totpop totpop90 change pctchange; title2 'Selected Vars from sf1x.moschlcos'; run;