hi ... another idea ... using Patrick's data set (adding an "OTHER" condition to the format) ... proc sql; create view distinctvaluelist as select distinct '$unit' as fmtname, upcase(name) as start, ' ' as hlo, case when type eq 'Rand' then '000' else '123' end as label from template union corr select '$unit' as fmtname, ' ' as start, 'o' as hlo, '999' as label from template; quit; proc format cntlin=distinctvaluelist; run; data sample; input unit :$10. @@; recoded = put(upcase(unit),$unit.); datalines; DATA DATAVALUE ACCOUNT OTHERVALUE ; Obs unit recoded 1 DATA 123 2 DATAVALUE 123 3 ACCOUNT 000 4 OTHERVALUE 999 if you want to stick with Patrick's PROC SQL plus a subsequent data step, maybe you would consider a couple changes (if a variable has the same value for all observations, you can use RETAIN to assign the value rather than an executable assignment that occurs at every data step iteration) ... proc sql; create view DistinctValueList as select distinct strip(upcase(name)) as start, type as new from template; quit; data fmt / view=fmt; retain fmtname '$unit'; do until (done); set distinctvaluelist end=done; label = ifc(new eq 'Rand', '000' , '123'); output; end; hlo = 'o'; label = '999'; output; run; proc format cntlin=distinctvaluelist; run;
... View more