x cd /pub/data/corrlst/Tools; %let pgm=usblocks2hsahrr; filename pgm "&pgm..sas"; *--Read the block to HSA and HRR (Hospital Referral Regions & Hospital Service Areas as coded by Nancy Marth at Dartmouth 8-2016. jgb, OSEDA, 8-6-16. --; libname corrlst '/pub/data/corrlst'; libname georef '/pub/data/georef'; *--we put the hssnames and hrrname data set in this directory--; ** libname user '/SAS_temp/user'; title "&pgm.: Process block to HSA-HRR Corr List"; %let filename=usblocks2HSAHRR; data corrlst.&filename(label='2010 cenus block to Hosp Svc Area and Hosp Rfrl Rgns 2016' drop=hsaname hrrname compress=no ) hsanames(keep=hsa hsaname compress=yes) hrrnames(keep=hrr hrrname compress=yes); filename csvin "/pub/data/corrlst/&filename..csv"; infile csvin dsd firstobs=2 truncover; length stab $2 esriid $15 _totpop _intptlat _intptlon 8 hsa $5 HSAname $80 hrr $3 HRRname $80 ; length State $2; input stab -- hrrname ; *----Testing!!!!!!!!!!!!!!---*; ***if stab gt 'al' then stop; State=substr(esriid,1,2); if hsa="-9" then do; *--these are water blocks that were not assigned codes--; hsa=' '; hrr=' '; end; else do; if length(hsa) lt 5 then hsa=translate(right(hsa),'0',' '); if hsa ne lag(hsa) then output hsanames; if length(hrr) lt 3 then hrr=translate(right(hrr),'0',' '); if hrr ne lag(hrr) then output hrrnames; end; output corrlst.&filename; drop _: ; run; *---we ran the next 3 steps to confirm there were no dups. The names are unique for the codes---; proc sql; create table georef.HRRnames as select distinct HRR, HRRname from hrrnames order by HRR, HRRname; create table georef.HSAnames as select distinct HSA, HSAname from hsanames order by HSA, HSAname; quit; proc datasets nolist library=corrlst; modify &filename; index create State; quit; proc print data=corrlst.&filename (obs=50); by State; where hsa ne ' '; run; proc print data=georef.HRRnames ; title2 "georef.HRRnames"; by hrr; id hrr; run; proc print data=georef.HSAnames ; title2 "georef.HSAnames"; by hsa; id hsa; run;