x cd /pub/sas/formats/Tools; %let pgm=wcfmats; filename pgm "&pgm..sas": *----create alternate format code in which we preappend the code to the label for an existing format code. Generates a new format code named <1st 6 chars of old format, if name that long>||wc . So, for example, $sumlev is used to generate $sumlevwc. . ---; %macro cnvt2wc(fname,library=sasctlgs,fnameout=,source=0,lenarg=,sourcelib=%str(/pub/sas/formats)); %if %superq(fnameout) = %str() %then %do; %local lfn memname; %if %substr(&fname,1,1)=%str($) %then %do; %let fname=%substr(&fname,2); %let type=c; %end; %else %let type=n; %let lfn=%length(&fname); %if &lfname <= 6 then fnameout=&fname.wc; %else fnameout=%substr(&fname,1,6)wc; %end; %if type=c %then %let memname=S&fname; %else %let memname=&fname; %if type=c %then %let memname=S&fname; %else %let memname=&fname; proc format cntlout=_cntlout %if &source %then %do; ; *<---end proc format stmt without a library= spec---; %include "&sourcelib(&memname..sas"; %end; %else %do; library=&library; select %if type=c %then($);&fname ; %end; run; data _cntlin; set _cntlout; fmtname="&fnameout"; length=length + &arglen +1 ; label=trim(start)||' '||label; max=length; run; proc print data=_cntlin(obs=50); title3 "_cntlin"; run; proc format library=&library cntlin=_cntlin; run; %mend cnvt2wc; options mprint; %cnvt2wc($sumlev,lenarg=3) run; data _null_; code='150'; put code= $sumlevwc.; run;