How to use Controlin or controlout option in proc format?

Posts: 47

How to use Controlin or controlout option in proc format?

Hello experts,

I have something like

proc format;

value $country

"United states of America"="US"



"Russia"= "RU";


about 22 countries list

I would like to know how to use control in and out format if that can be used  to parametrize user defined formats. Is it possible to make this existing proc format statements(like the above) read a new a new list of  different countries and their label by using a parameter?  I see the next list is having countries staring from "argentina"= "arg"...."India"=Ïnd" and also the point to note is that the count of countries tend to differ too depending on what's in the next list..A macro will help ?

Any help would mean a lot. Thanks

Super Contributor
Posts: 644

Re: How to use Controlin or controlout option in proc format?

Posted in reply to Allaluiah

You can use the cntlout= option to copy all existing formats to a SAS dataset.  This can be distributed for review or stored as a backup.  It can be exported to Excel for amendment and then imported back into SAS.  There are a lot of columns but the main ones to review are called start and end, the start and end values for a range covered by a single formatted value.  Additional rows can be entered if required.  The modified table can then be read back into proc format using cntlin=.  Make sure no-one has renamed any of the columns.

Proc format cntlin=work.formatlist ; quit ;

You can also create a cntlin table to add a new format into the library, from a lookup table in the database.  At a minimum you need to define s start column, a label column to hold the formatted value, and a fmtname column as the name of the format.  A HLO column is often useful to define how the format will handle out of range values.


Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation