x cd /pub/data/corrlst/Tools; %let pgm=sbg2k_careconn05; filename pgm "&pgm..sas"; *---Create corr lists relating the split-BG (sumlev=090) and split tract (sumlev=080) geos to 2005 service areas and service areas/complete bgs. For the Care Connection 13-county Warrensburg area. jgb, Apr, 2005 ---*; libname corrlst '/pub/data/corrlst'; %*libname (sf12000x); libname user '/SAS_temp/user'; %libname(mable2k) ; filename csvin '/pub/data/corrlst/blk2careconnsa.csv'; filename sasfmat '/pub/sas/formats/Sccsvca.sas'; *<----SAS format code defining $ccsvca. format --; title "&pgm: Create 2000 Split BG (090 level) to Care Connection Service Areas, 2005"; options ls=132 ps=120; %let sl90vars=state county cousubfp placefp tract urbanrur bg; %let sl80vars=state county cousubfp placefp tract; *---we just copied and pasted from the log the values of the list of counties---; %let counties="29013","29015","29033","29039","29041","29083","29085","29101","29107","29159","29185","29195","29217"; /* =======================Begin comment================ *---Read the CSV file, create the basic block to sa dataset as well as the service area names set---; data csvin(drop=areaname) areanames(keep=careconnsa areaname); infile csvin firstobs=3 dsd ; length _esriid $15 Areaname $24 careconnsa _incode $3; length county $5 tract $7 block $4; input _esriid areaname _incode; if _incode ne lag(_incode) then do; careconnsa=_incode; if length(_incode)=1 then careconnsa='0'||_incode; retain careconnsa; if length(_incode)=3 then areaname=trim(areaname)|| ' '||upcase(substr(_incode,3,1)); output areanames; end; county=substr(_esriid,1,5); tract=substr(_esriid,6,4)||'.'||substr(_esriid,10,2); block=substr(_esriid,12,4); output csvin; drop _: ; run; proc sort data=areanames out=areanames2 nodupkeys; by careconnsa; run; %genfmat(fmatname=carecosa,sasin=areanames2,arg=careconnsa,arglen=3,textfile=sasfmat,labellen=32,source=1); run; *--This will generate the $carecosa format code that converts the service area codes to names--; proc sort data=csvin; by county tract block; run; proc sql noprint; select distinct county into :counties separated by '","' from csvin; quit; %let counties="&counties"; %put counties=&counties; ======================End comment================== */ *---Get all the required sumlev090-defining vars and the 2k pop from the mable database and merge this with the csvin data by block---; data blocks(drop=msg) badblocks(keep=county tract block msg); merge csvin(in=incsvin) mable2k.moblks (where=(county in (&counties)) in=inmable) mable2k.moblks2(where=(county in (&counties)) in=inmable2 rename=(ur=urbanrur)); by county tract block; length bg12 $12; bg12=county||compress(tract,'.')||BG; if not (incsvin and inmable and inmable2) then do; if not incsvin then msg='Not in corrleation list '; else msg='Not in MABLE sets'; output badblocks; end; else output blocks; retain state '29'; keep &sl90vars block careconnsa pop2k bg12 msg; run; proc print data=badblocks(obs=100); title2 'badblocks'; run; *---create a sorted block-level set out of the mable2k block to everything correlation list--; proc sort data=blocks; by &sl90vars careconnsa bg12; run; *--split bg (SumLev 090) to service area---; %corrwt(setin=blocks,setout=corrlst.mosbg2k_careconnsa05, g1=&sl90vars, g2=careconnsa, wtvar=pop2k,keepwt=1) run; proc print data=corrlst.mosbg2k_careconnsa05(obs=50); title2 "corrlst.mosbg2k_careconnsa05(obs=50)"; by county cousubfp placefp tract; id county cousubfp placefp tract; run; *---split bg to service area/ 150-type BG---; %corrwt(setin=blocks,setout=corrlst.mosbg2k_careconnsabg05, g1=&sl90vars, g2=careconnsa bg12, wtvar=pop2k,keepwt=1) run; proc print data=corrlst.mosbg2k_careconnsabg05(obs=50); title2 "corrlst.mosbg2k_careconnsabg05(obs=50)"; by county cousubfp placefp tract; id county cousubfp placefp tract; run; proc sort data=blocks out=blocks2; by &sl80vars careconnsa bg12; run; *--split tract (SumLev 080) to service area---; %corrwt(setin=blocks2,setout=corrlst.mostr2k_careconnsa05, g1=&sl80vars, g2=careconnsa, wtvar=pop2k,keepwt=1) run; proc print data=corrlst.mostr2k_careconnsa05(obs=50); title2 "corrlst.mostr2k_careconnsa05(obs=50)"; by county cousubfp placefp tract; id county cousubfp placefp tract; run; *---split tr to service area/ 150-type BG---; %corrwt(setin=blocks2,setout=corrlst.mostr2k_careconnsabg05, g1=&sl80vars, g2=careconnsa bg12, wtvar=pop2k,keepwt=1) run; proc print data=corrlst.mostr2k_careconnsabg05(obs=50); title2 "corrlst.mostr2k_careconnsabg05(obs=50)"; by county cousubfp placefp tract; id county cousubfp placefp tract; run;