x cd /mscdc/sas/formats/Tools; %let pgm=uscnty; filename pgm "&pgm..sas"; *--experimental setup to create a set of state-level format codes named $alcnty, $akcnty, ... $wycnty that will provide names for FIPS county codes for individual states. Then we define $uscnty in terms of the individual state codes, i.e. with value $uscnty '01001'-'01999'=[$alcnty] '02001'-'02999'=[$akcnty] ...; title 'This is the uscnty module in sasfmats/Tools: Generate state level ' 'County Format Codes'; libname user '/SAS_temp/usersdl'; /* ********************************************************* proc format cntlout=county library=library.formats; select $county; run; data countyv/view=countyv; set county; length state stab $2; state=substr(start,1,2); if state gt '04' then stop; ******testing****; stab=put(state,$fipstab.); drop fmtname min max default mult fill fuzz--hlo; run; =================================== */ data cntlin; set countyv; by state; retain type 'C'; retain _lb 'AD'x _rb 'BD'x; drop _lb _rb; *--bracket codes; if first.state then do; fmtname=stab||'CNTY'; retain fmtname; end; output; start=substr(start,3,3); end=start; output; if last.state then do; end=state||start; start=state||'001'; label=_lb||'$'||trim(fmtname)||'.'||_rb; fmtname='USCNTY'; output; end; run; proc print data=cntlin(obs=100); title2 'cntlin'; run; proc sort data=cntlin; by fmtname; run; proc format cntlin=cntlin; run; data _null_; arg='001 '; put arg= arg $alcnty.; arg='04001'; put arg= arg $azcnty.; arg='04007'; put arg= arg $uscnty.; run;