In brief, you need a table called a SAS control table in a specified layout. Then you just invoke proc format cntlin = your_control_table ; quit ; At a minimum the control table needs to have 3 columns which must be called start, label and fmtname. The first is the initial value, the second is the formatted value, and the third is the name to be assigned to the format. Values in the fmtname column are repeated for every row. You can create this table in SQL or in a datastep (imagining that the only possible marks are 0, 590, 60, 70, 80) proc SQL ; create table fmtcntl as select mark as start , grade as label , 'gradefmt' as fmtname from grades_lkup ; quit ; proc format cntlin = fmtcntl ; quit ; You can only have one cntlin table per proc format invocation, but the control table can have concatenated lists of lookups if each has thier own fmtname. If you want to create a character format you have to add an additional column called type which would hold the value 'C' for each row. (The default is 'N' for a numeric format). Fir a numeric informat, type = 'I'. Other columns can hold additional information: eg end is the end value of a range. You need that if your grade format has a continuous integer range. Thus for your data (where end values have to be inferred) data fmtcntl ; length start end 8 grade $ 4 ; retain fmtname 'gradefmt' ; set grades_lkup end = lastrow ; start = lag (mark) ; end = mark - 1 ; label = lag (grade) ; if _N_ = 1 then return ; output ; if lastrow then do ; start = mark ; end = 100 ; label = grade ; output ; end ; drop mark ; run ; This may seem more effort than is worth for a simple format, as in you example, but if you lookup table contains more than a few rows it can be worthwhile especially for lookup tables which are straight transformations. Richard in Oz
... View more