x cd /pub/data/corrlst/Tools; %let pgm=mobl2libd; filename pgm "&pgm..sas"; *----Create the 2k census block to library district corrleation list using dbf file created by GRC, N. Mattox, 2002. Outputs are: corrlst.&pgm georef.libdists (with assigned Distcode and DistrictName) $libdnamme. -- SAS format code, created from the above georef set using geffmat. jgb, mcdc contract work, Jan, 2003. ----*; filename dbfin '../liblk00.dbf'; libname corrlst '/pub/data/corrlst'; libname georef '/pub/data/georef'; libname user '/SAS_temp/user'; filename format '/pub/sas/formats/Slibdname.sas'; title "Creating corrlst.&pgm : Missouri Block to Library District Corr List"; /*<=========================Comment out===================================== *---Begin by converting the dbf file to a SAS dataset--; proc dbf db4=dbfin out=corrlst; run; *--This set has only 2 vars: libdist, the name of the district and relate the equiv of esriid, the block geocode-; proc sql; create table districts as select distinct libdist from corrlst order by libdist; run; proc sort data=corrlst(rename=(libdist=DistrictName)); by DistrictName; run; *---There are 172 library districts----------; data georef.libdists(label='Missouri library districts with MCDC-generated Codes'); length Distcode $3 DistrictName $64; set districts; if libdist=' ' then delete; _nlib+1; distcode=put(_nlib,z3.); DistrictName=libdist; keep distcode DistrictName; run; *---And create the $libdname format code that can be used to put the name with the code---; %genfmat(sasin=georef.libdists,arg=distcode,labelvar=DistrictName,labellen=64, textfile=format,fmatname=libdname,runproc=1); run; data _null_; infile format; input; file print; put _infile_; title2 'Listing of $libdname format code'; run; *----Now get the just-created lib district code into the corrlst dataset and break down their relate variable (comaprable to our esriid) into its components000; proc sort data=georef.libdists out=libdists; by DistrictName; run; proc sort data= sf12000x.moblks(keep=county tract block totpop totpop90 ) out=moblks; by county tract block; run; data mobl2libd; length County $5 Tract $7 Block $4 Distcode $3; merge libdists(in=in1) corrlst(in=in2); by DistrictName; if not (in1 and in2) then do; if in2 and DistrictName=' ' then distcode='999'; else do; put /_all_; abort abend; end; end; county=substr(relate,1,5); tract=substr(relate,6,4)||'.'||substr(relate,10,2); block=substr(relate,12,4); drop relate DistrictName; Distname=Distcode; format Distname $libdnam.; run; proc sort data=mobl2libd; by county tract block; run; ===========================End commented out================================ */ data corrlst.&pgm(label='MO 2000 Census Block to Library District'); merge mobl2libd (in=in1) moblks(in=in2); by county tract block; if not (first.block and last.block) then do; if first.block then put / county= tract= block= distcode=; else put +20 distcode=; if not first.block then delete; end; format county $5.; rename totpop=pop2k; if not (in1 and in2) then do; _nbad+1; drop _nbad; if _nbad le 100 then put _all_; else abort abend; end; run; proc contents data=corrlst.&pgm; proc print data=corrlst.&pgm(obs=100); by county; id tract block; title2 "Sample Listing of corrlst.&pgm"; run;