How Do I Build a Format from a Dataset?
A very efficient way of defining Formats and Informats is to use an Input Control Data Set with Proc Format, rather than writing VALUE or INVALUE statements.
For example, suppose you have the following data set and you wish to create a simple numeric format to convert outlet codes into their actual names:
Outcode Outname 101 Aberdeen 102 Altrincham 103 Ashford 104 Barnsley 105 Basildon 106 Basingstoke 107 BathFirst
Create the Input Control Data Set with the variables START, LABEL and FMTNAME. Then run a Proc Format step which points to the CNTLIN data set as follows.
data work.outfmt(keep=start label fmtname); set work.outlets(rename=(outcode=start outname=label)); fmtname='outfmt'; run; proc format library=work cntlin=work.outfmt; run;
335 proc format library=work cntlin=work.outfmt; NOTE: Format OUTFMT has been output. 336 run;
This technique is particularly useful when formats need to be created dynamically at run time.