x cd /pub/data/georef/Tools; %let pgm=compare_greatdatazips; filename pgm "&pgm..sas"; *---Run compare of ZIP codes in our zcta_master12 with those on the free zipcodes database sent by Paul Duggan of GreatData.com 8-13. Want to see how many "missing" ZIPs there are in ZCTA_master. ---; libname georef '/pub/data/georef'; libname user '/SAS_temp/user'; filename zipsin '/pub/data/georef/greatData_freezipcodes.csv'; *--the file downloaded from http://greatdata.com/free-zip-code-database ---*; libname temp '/pub/data/temp'; options nofmterr; data mcdczips; length ZIP $5 State $2 zcta5 $5 ZIPName $64 Fipco $5; set georef.zcta_master ; where psf=1; keep zip state fipco county placefp ZIPName PlaceName; zip=zcta5; fipco=county; _savezipname=ZIPName; output; If Naltzips then do _i=1 to Naltzips; zip=scan(altzips,_i); ZIPName='Alt for '||zcta5|| ' '||_savezipname; output; end; keep ZIP State ZIPname Fipco county placefp placename IntptLat IntPtLon; run; proc sort; by zip; run; data gdzips; infile zipsin dsd firstobs=2; length ZIP $5 State $2 CityGD CountyGD $64 Lat Long 8; input ZIP -- Long; format lat long 7.2; if state in ('PR','VI','AE') then delete; if length(ZIP) < 5 then zip=translate(right(ZIP),'0',' '); *<---insert leading zeros--; run; proc sort; by zip; run; data temp.mcdconly temp.gdataonly temp.inboth; merge mcdczips(in=in1) gdzips(in=in2); by zip; if in1 and in2 then output temp.inboth; else if in1 then output temp.mcdconly; else output temp.gdataonly; run; options obs=200; proc print data=temp.mcdconly; id zip; title 'temp.mcdconly'; run; proc print data=temp.gdataonly; id zip; title 'temp.gdataonly'; run; proc print data=temp.inboth; id zip; title 'temp.inboth'; run;