x cd /pub/data/stf901/Tools; %let pgm=moschls00; filename pgm "&pgm..sas"; *--Coded by John Blodgett, OSEDA, Aug 2001. Under contract with Mo Census Data Center. Aggregate/convert 1990 full stf1 data set at the (1990) census block level to create: --> stf901.moschls00 (complete school districts, 2000 geographic defn but 90 data) and --> sftf901.moschlcos00 (similar to above but for districts split by counties). --*; libname stf901 '/pub/data/stf901'; libname user '/SAS_temp/user'; options msglevel=i ; options compress=yes; /*<=========================Comment out===================================== *---create input set for aggregation--; data aggin; set stf901.moblks00; keep sumlev ncescode county _numeric_; if sdelm ne ' ' and sdelm ne '99999' then do; sumlev='se2'; ncescode=sdelm; output; end; if sduni ne ' ' then do; sumlev='su2'; ncescode=sduni; output; end; run; proc datasets library=user; modify aggin; index create byvars=(sumlev ncescode county); quit; %agg(aggin=aggin,aggout=aggout,aggby=sumlev ncescode county, aggvars=%str(p1i1--h55i4), agglvl=2, MEANS=P17AI1 H17AI1 H18AI1 H18AI2, MWEIGHTS=P2I1 H2I1 H3I1 H3I2 , grand=1) run; data stf901.moschls00(label='1990 stf1 data by 2000 School District Geo' drop=partflag county cnty compress=yes) stf901.moschlcos00(label='1990 stf1 by 2000 School District/Counties' compress=yes); length sumlev $3 areaname $56 geocode $12 desedist $6 county $5 cnty $3 ncescode $5 partflag $1; set aggout (where=(_lvl_ ne 99)); by sumlev ncescode _lvl_ notsorted; if ncescode='99999' then areaname='Not in any unified district'; else areaname=put(ncescode,$school.); desedist=put(ncescode,$schcnvt.); *--add dese codes and the dist name-; link domedians; if _lvl_=1 then do; *--its a district within county sum--; geocode=ncescode||'-'||county; cnty=substr(county,3,3); *--See if it is split across counties--; if not (first._lvl_ and last._lvl_) then do; partflag='y'; areaname=trim(areaname)||'/'||put(cnty,$mocnty.); end; else partflag='n'; output stf901.moschlcos00; end; else do; if sumlev='su2' then sumlev='sdu'; else sumlev='sde'; geocode=ncescode; output stf901.moschls00; end; label ncescode='NCES School District Code' desedist='Mo Dept of Elem & Sec Educ. District Code' partflag='District Spans Counties?'; drop _lvl_ _nag_; return; domedians: *---code taken from the sascode(aggstf1.sas) module. Estimate percentiles using median macro--; RETAIN HV1 15000 HV2 HV3 HV4 HV5 HV6 HV7 HV8 5000 HV9 10000 HV10 15000 HV11 HV12 HV13 HV14 HV15 25000 HV16 HV17 50000 HV18 HV19 50000 HV20 200000 R1 100 R2-R14 50 R15 250 R16 500; ARRAY HVALUE HV1-HV20; *<--MEASURES OF THE "WIDTHS" OF H23 CELLS; ARRAY RENTS R1-R16; *<--MEASURES OF THE "WIDTHS" OF H32 CELLS; ARRAY NVALUE H23I1-H23I20; ARRAY NRENTS H32I1-H32I16; %MEDIAN(INTSIZE=HVALUE,INTVALS=NVALUE,Q1=H23AI1,MDN=H23BI1,Q3=H23CI1) %MEDIAN(INTSIZE=RENTS,INTVALS=NRENTS,Q1=H32AI1,MDN=H32BI1,Q3=H32CI1, SAMESTEP=1) *--ROUND ALL VALUES TO NEAREST DOLLAR--*; H23AI1=ROUND(H23AI1); H23BI1=ROUND(H23BI1); H23CI1=ROUND(H23CI1); H32AI1=ROUND(H32AI1); H32BI1=ROUND(H32BI1); H32CI1=ROUND(H32CI1); P17AI1=ROUND(P17AI1,.01); H17AI1=ROUND(H17AI1,.01); H18AI1=ROUND(H18AI1,.01); H18AI2=ROUND(H18AI2,.01); return; drop hv1-hv20 r1-r16; *<---constant values used to re-estimate medians---; run; proc sort data=stf901.moschls00; by desedist; run; proc sort data=stf901.moschlcos00; by desedist county; run; ===========================End commented out================================ */ *-------------Print Some ID fields and do some means to verify we did not lose any data------------*; proc print data=stf901.moschls00(obs=20 keep=_char_ p1i1 h1i1 h23bi1); title2 'Sample Data from stf901.moschls00'; run; proc means data=stf901.moschls00 maxdec=0 n min max sum mean; var p1i1; title2 'Mean Statistics Based on moschls00'; run; proc print data=stf901.moschlcos00(obs=20 keep=_char_ p1i1 h1i1 h23bi1); title2 'Sample Data from stf901.moschlcos00'; run; proc means data=stf901.moschlcos00 maxdec=0 n min max sum mean; var p1i1; title2 'Mean Statistics Based on moschlcos00'; run; proc datasets library=stf901 nolist; modify moschls00; index create geocode; modify moschlcos00; index create geocode; quit;