x cd /mscdc/sas/formats/Tools; %let pgm=gencomet; filename pgm "&pgm..sas"; *--Generate the latest version of the $comet format code which will convert FIPS county codes to MSA or CMSA codes. Uses %genfmat macro to create a source modules in the sasfmats library. Try to always keep this module as the most recent codes.--; *--jgb 7-7-97--; %libname(popests); %let yr=96; ****************Year for the codes (updated as of July)--; filename text '/mscdc/sas/formats/Scomet.sas'; data cntymets; set popests.uscom&yr; where msacmsa ne ' '; length arg $6 result $6; *--assign metro type: N for new england, M for MSA, C for CMSA--; if state in('09','23','25','33','44','50') then mtype='N'; else mtype='M'; if pmsa ne ' ' then mtype='C'; *--consolidate MSA.--; arg=county; result=msacmsa||mtype; output; if pmsa ne ' ' then do; substr(arg,6,1)='P'; result=pmsa||'P'; output; end; keep arg result mtype pmsa; run; %genfmat(setin=cntymets,fmatname=comet, arglen=6,argvars=arg,labelvar=result,labellen=5, other=' ',savedoc=0) *--test it--; data wrong; set popests.uscom&yr(keep=county msacmsa pmsa); if pmsa ne ' ' then do; mtype='P'; length arg $6; arg=county||"P"; if put(arg,$comet4.) ne pmsa then output wrong; end; mtype='M'; if put(county,$comet4.) ne msacmsa then output; run; proc print data=wrong; title2 'Problem Counties'; run;