Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

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.

Program:

  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;

Log:

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.