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.


The GROUPFORMAT option can be used in the data step to apply by-group processing to formatted ranges of values.

In order to use this option, the BY variable in question must have the relevant format applied. This option can only be used in the data step. Reading a SAS data set, using the GROUPFORMAT option on the BY statement, will then generate FIRST. and LAST. variables based on the formatted values as opposed to the raw column values. This is particularly useful when it is desirable to perform by-group processing when working with continuous data. See example below which totals up the number of employees in each salary band and produces a report.

data payroll;
  input staffno $ salary;
001 13592.45
002 8870.23
003 12672.26
004 23760.82
005 10512.63
006 7520.61 
007 28512.66
008 14840.27
009 47520.38
020 23760.44

proc format;
   value salary_bands
   0 - < 20000 = 'Under 20k'
   20000 - < 30000 = 'Between 20-30k'
   30000 - high = 'Over 30k';
proc sort data=payroll;
   by salary;
data employee_salary;
   format salary salary_bands.;
   set payroll;
   by groupformat salary;

   if first.salary then count_staff=0;
   if last.salary then output;

proc print data=employee_salary noobs label;
   label count_staff = 'No. of Employees'
                  salary = 'Salary Bands';