Previous data sets:
[pre]
data all_append_and_edc_and_vars2;
 set all_append_and_edc_and_vars;
  datim2 = datim;
run;
proc sort data=all_append_and_edc_and_vars2; by route; run;
data routes(keep = route Program ProcessEngineer BatchEngineer);
 set RF300L3.W_status_wiplot;
where Lot_ID = "&sel_lot";
run;
proc sort data=routes; by route; run;
data output_data;
 merge all_append_and_edc_and_vars2 routes;
 by route;
run;
[/pre]
This is the output (copied from HTML page)
Header:Lot: P110006 Route: SS_RECAP4 Facility: PLINE200           
PE: SHAHAR BE: DUBOISB Program: PR MEMS-BASED PROJECTS                                                                                                       
Rowheader                                                                                                   
Datim Operation Step EVENT_TYPE HoldCode Annotation Prio T_Duration NrWafers SelToolList PreferredTool MainStepService Standard 
Data
04JAN11:10:18:07 7000-PRODUCT_INFORMATION 01-LotStart Create     4 0:00 23   NoTool-sProductInfo sProductInfo Std 
04JAN11:10:18:11 7000-PRODUCT_INFORMATION 01-LotStart Hold Lot Fmhl Wating For Fabmanager to Relea... 4 141:32 23   NoTool-sProductInfo sProductInfo Std 
10JAN11:07:50:32 7000-PRODUCT_INFORMATION 01-LotStart Release Lot -Fmhl   4 0:01 23   NoTool-sProductInfo sProductInfo Std 
10JAN11:07:51:11 7001-WAFER_SELECT 03-ComposeLot Move Out     4 1:51 23 INNOLAS INNOLAS sComposeLot Std 
10JAN11:09:41:32 7001-WAFER_SELECT 03-ComposeLot Object Annotation   Dispatched for service: PLINE2... 4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:09:41:54 7001-WAFER_SELECT 03-ComposeLot Move In     4 0:49 23 INNOLAS INNOLAS sComposeLot Std 
10JAN11:09:41:57 7001-WAFER_SELECT 03-ComposeLot Event Annotation   Entity: PLINE200.INNOLASMode :... 4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:09:42:48 7001-WAFER_SELECT 03-ComposeLot VIEW EDC DATA      4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:09:42:53 7001-WAFER_SELECT 03-ComposeLot Event Annotation   Entity : PLINE200.INNOLASMode ... 4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:09:43:25 7001-WAFER_SELECT 03-ComposeLot VIEW EDC DATA      4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:09:43:29 7001-WAFER_SELECT 03-ComposeLot Event Annotation   Entity : PLINE200.INNOLASMode ... 4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:09:44:01 7001-WAFER_SELECT 03-ComposeLot VIEW EDC DATA      4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:09:44:05 7001-WAFER_SELECT 03-ComposeLot Event Annotation   Entity : PLINE200.INNOLASMode ... 4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:10:30:22 7001-WAFER_SELECT 03-ComposeLot Object Annotation   Dispatched for service: PLINE2... 4 0:00 .   INNOLAS sComposeLot Std 
10JAN11:10:30:31 8600-DRYOX_OXIDATION 02-Clean Move Out     4 0:50 23 F5_2;POSEIDON;SORT_OVENS P3_NITRIDE sDeposDryOx Std 
10JAN11:11:20:36 8600-DRYOX_OXIDATION 02-Clean Hold Lot EqFail spc to do na shutdown 4 22:09 23 F5_2;POSEIDON;SORT_OVENS P3_NITRIDE sDeposDryOx Std 
11JAN11:09:29:59 8600-DRYOX_OXIDATION 02-Clean Release Lot -EqFail Dryox is UP 4 4:02 23 F5_2;POSEIDON;SORT_OVENS P3_NITRIDE sDeposDryOx Std 
11JAN11:13:30:49 8600-DRYOX_OXIDATION 02-Clean Object Annotation   Dispatched for service: PLINE2... 4 0:00 .   P3_NITRIDE sDeposDryOx Std 
11JAN11:13:31:29 8600-DRYOX_OXIDATION 02-Clean Move In     4 1:02 23 F5_2;POSEIDON;SORT_OVENS P3_NITRIDE sDeposDryOx Std 
11JAN11:13:39:11 8600-DRYOX_OXIDATION 02-Clean Event Annotation   Entity : PLINE200.SORT_OVENSMo... 4 0:00 .   P3_NITRIDE sDeposDryOx Std 
11JAN11:13:44:44 8600-DRYOX_OXIDATION 02-Clean Object Annotation   Dispatched for service: PLINE2... 4 0:00 .   P3_NITRIDE sDeposDryOx Std 
it continues for many many rows: result: HTML page looks very very crowded, so customer wants to remove all fields which are recurring ( grouping is needed ).
Also I have this object that changes from route and facility. If the object changes, i want a different table (with different header information). So I need byvariables facility and route.
But it is like a history of the object, so i want to sort it on date. But sorting on Datim doesn't work, so I added datim2. Now the sorting works, but the grouping doesn't.
It is a hard example, I know 
🙂
All these outputs use the same input data set, sorted the same way
Output example without grouping:
http://img232.imageshack.us/i/sasforum.jpg/
Output example with grouping:
http://img190.imageshack.us/i/sasforum2.jpg/
here you can see that it doesn't work correctly, same values get repeated under each other for operation and step.
Output example with grouping but wrong sort:
 /*define datim2 / order order=internal noprint;*/
http://img22.imageshack.us/i/sasforum3.jpg/
look at the datim fields...
So I hope it is clear enough now to give me some help 
🙂