x cd /mscdc/data/stf903x/Tools; %let pgm=zipxys; filename pgm "&pgm..sas"; *--create a special sas dataset with x-y coords for u.s. zips in zip order and then use it to create a special view-extension of stf903x.uszips named stf903x.uszipsxy; %libname(zipeq90x); libname stf903x '/mscdc/data/stf903x'; title 'stf903x/zipxys: Adding x,y Coordinate and aerasqmi to uszips ' '(creating stf903x.uszipsxy)'; /*<=========================Comment out===================================== *---strip off the xys and sort by zip--; data xys; set zipeq90x.uszips; keep zip xpcentrm ypcentrm xpcentrl ypcentrl areasqmi; rename xpcentrm=xcentrm ypcentrm=ycentrm xpcentrl=intptlng ypcentrl= intptlat; *<---for consistency with stf903x filetype vars--; label areasqmi='LAND ONLY area sq miles'; run; proc sort out=stf903x.zipxys(label='ZIPs in ZIP order with x-y coords'); by zip; run; *--use view to add coordinates to stf903x.uszips---; data stf903x.uszipsxy (label='Same as uszips + x-y coords')/ view=stf903x.uszipsxy; merge stf903x.zipxys(in=inxys) stf903x.uszips(in=instf3 drop=landsqmi areasqmi); by zip; if inxys and instf3; ATTRIB landsqmi label='Land Area Sq Mi (same as aresqmi)' length=5 format=8.3; landsqmi=areasqmi; poppsqmi=totpop/areasqmi; label poppsqmi='Persons per (land only) Sq Mi'; run; proc print data=stf903x.uszipsxy(obs=50); var geocode zip state slvl areasqmi xcentrm ycentrm intptlng intptlat totpop; title2 'Selected Variables (including added items) From stf903x.uszipsxy'; title3 'Coordinate and Land Area from zipeq90: Coords are *Population* ' 'Centroids -- Block centroids weighted by Pop'; run; proc contents data=stf903x.uszipsxy; run; ===========================End commented out================================ */ *----Running under SAS v8.1 to create the new uszips data set in v8 engine with xy coords included---; libname stf903x8 v8 '/mscdc/data7/stf903x'; data stf903x8.uszips; merge stf903x.zipxys(in=inxys) stf903x.uszips(in=instf3 drop=landsqmi areasqmi); by zip; if inxys and instf3; ATTRIB landsqmi label='Land Area Sq Mi (same as aresqmi)' length=5 format=8.3; landsqmi=areasqmi; poppsqmi=totpop/areasqmi; label poppsqmi='Persons per (land only) Sq Mi'; run;