x cd /pub/data/corrlst/Tools; %let pgm=zip_hsahrr; filename pgm "&pgm..sas"; *--Read the downloaded ZIP to HSA and HRR (Hospital Referral Regions & Hospital Service Areas per http://www.dartmouthatlas.org/tools/downloads.aspx?tab=39 --; libname corrlst '/pub/data/corrlst'; %libname (georef); libname user '/SAS_temp/user'; %let filename=ZipHsaHrr14; /*<=========================Comment out===================================== data corrlst.&filename(label='ZIP to Hosp Svc Area and Hosp Rfrl Rgns 2014' compress=yes); filename csvin "/pub/data/corrlst/&filename..csv"; infile csvin dsd firstobs=2 missover; length ZIP ZCTA HSA $5 _hsacity $80 hsastab $2 HRR $3 _hrrcity $80 hrrstab $2; input ZIP HSA--hrrstab; length HSAname HRRname $80; HSAname=trim(_hsacity)||', '||hsastab; HRRname=trim(_hrrcity)||', '||hrrstab; ZCTA=put(zip,zpzcta.); *---We look use this format table lookup to see if we have a ZIP that is not a ZCTA but can be related to one; if zcta=' ' then put zip= ' not found.'; 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 HRRnames as select distinct HRR, HRRname from corrlst.&filename order by HRR, HRRname; create table HSAnames as select distinct HSA, HSAname from corrlst.&filename order by HSA, HSAname; quit; data hrrdups; set hrrnames; by hrr; if not first.hrr and last.hrr; if first.hrr then put; put hrr +1 hrrname; run; data hsadups; set hsanames; by hsa; if not first.hsa and last.hsa; if first.hsa then put; put hsa +1 hsaname; run; ===========================End commented out================================ */ *---See if we have all the ZCTAs on the file----; proc sort data=georef.zcta_master(rename=(zcta5=zcta)) out=zctas; by zcta; run; proc sort data=corrlst.&filename(keep=zip zcta) out=corrlstzs; by zcta; run; data _null_; merge zctas(in=inzctas) corrlstzs(in=inclist); by zcta; if not (inzctas and inclist); put zcta= zip= inclist= inzctas= ; run;