x cd /pub/data/stf903/Tools; %let pgm=uszips; filename pgm "&pgm..sas"; /* Convert the "STF3B" ZIP file to SAS datasets. Nov. 2002 This is a rerun after original conversion was lost. Rerun 7-2003. We create a series of stf903 datasets and subset views: uszips: Complete 800-level ZIPs with primary county code. mozips, ilzips and kszips: State level subsets (views). John Blodgett, OSEDA, U of Mo Outreach and extension. Under contract with the Missouri Census Data Center */ title "stf903.&pgm: Conversion Run"; *filename in '/pub/data/stf903/rawdata/da6116.zip*'; filename in '/tmp/storage/stf903rawfiles/da6116.zip*'; libname stf903 '/pub/data/stf903'; options compress=yes; *----We are converting complete ZIP code summries (slvl=800) and 820 zip/county summaries, *** separately ***-; %macro slvl800; SumLev=slvl; if slvl='820' then do; input; *--release rec; delete; end; length pcounty $5 ; pcounty=put(zip,$zipcods5.); *<---look up the "primary" county for the ZIP---; state=substr(pcounty,1,2); cnty=substr(pcounty,3,3); drop geocomp chariter fipco pcounty cnty cousub: place: reg div msacmsa pmsa msas ccce cmsa2 areasqmi arealand areawat intpt: xci urbanrur xci partflag psadc spflag sac9 anrc aian: artli tract bg funcstat gcuni urbarea cntysc uasc statece cd ; label county='Primary County'; county=pcounty; *<-------------------NOTE!--------------------; %mend slvl800; %macro slvl820; %*--invoked as exit macro to cause only 820 - split zip - records to be read and converted--; SumLev=slvl; if slvl='800' then do; input; *--release rec; delete; end; drop geocomp chariter msas ccce cmsa2 areasqmi arealand areawat intpt: xci urbanrur xci partflag psadc spflag sac9 anrc aian: artli tract bg funcstat gcuni urbarea cntysc uasc statece cd ; %mend slvl820; options MPRINT; *--invoke the conversion macro for the 800 (complete ZIP) summaries---; %stf903c(setout=stf903.uszips, subfile=B, geofiltr=slvl800, obs=999999, attribs=1, cnvtmls=0) SumLev=slvl; run; proc print data=stf903.uszips(obs=50 keep=_char_ p1i1); title2 'Partial Print of uszips'; run; proc tabulate data=stf903.uszips(keep=state zip p1i1); title2 'Check Sums of Total Pop By State'; class state; format state $state.; var p1i1; table all state,p1i1*(n='NZips' sum='TotalPop'*f=comma12.); run; *--invoke the conversion macro for the 820 (ZIP within county) summaries---; %stf903c(setout=stf903.uszipcos, subfile=B, geofiltr=slvl820, obs=999999, attribs=1, cnvtmls=0) SumLev=slvl; run; proc print data=stf903.uszipcos(obs=50 keep=_char_ p1i1); title2 'Partial Print of uszipcos'; run; proc tabulate data=stf903.uszipcos(keep=state zip p1i1); title2 'Check Sums of Total Pop By State'; class state; format state $state.; var p1i1; table all state,p1i1*(n='NZipcos' sum='TotalPop'*f=comma12.); run; *---And now create the indices----; proc datasets nolist library=stf903; modify uszips; index create zip; index create state; index create stzip=(state zip); modify uszipcos; index create zip; index create state; index create stzip=(state zip); quit; *---and now create the state views---; proc sql; create view stf903.mozips as select * from uszips where state='29'; create view stf903.ilzips as select * from uszips where state='17'; create view stf903.kszips as select * from uszips where state='20'; create view stf903.mozipcos as select * from uszipcos where state='29'; create view stf903.ilzipcos as select * from uszipcos where state='17'; create view stf903.kszipcos as select * from uszipcos where state='20'; quit; proc contents data=stf903.uszips position; title2 'Contents Report'; run cancel;