Purpose
create format from a dataset
%macro format_gen(fmtdata=,fmtcod=,fmtnam=,nam=,type=C);
%if %nrbquote(&nam) eq %nrbquote() %then %do;
%let nam=&fmtcod;
%end;
proc sql;
create table temp_format as
select distinct
&fmtcod as start,
&fmtnam as label,
%if &type=C %then %do; "$&nam" %end; %else %do; "&nam" %end; as fmtname,
"&type" as fmt_type
from &
fmtdata.;
quit;
proc format library=work cntlin=temp_format;
run;
%mend;