I believe the following two macros and subsequent sample code can generate what you want. The code could be a bit more robust, but that's for you to add, since I don't know the specifics of your requirements.
MACRO &LAB GRP GBLC &GROUPS(500),&USERS(500) GBLA &NUMGRPS,&NUMUSRS,&USRBEG(500),&USREND(500) .* &NUMGRPS SETA &NUMGRPS+1 &GROUPS(&NUMGRPS) SETC '&LAB' .* LCLA &IX &IX SETA 1 &USRBEG(&NUMGRPS) SETA &NUMUSRS+1 .* .USRLOOP ANOP &NUMUSRS SETA &NUMUSRS+1 &USERS(&NUMUSRS) SETC '&SYSLIST(&IX)' &IX SETA &IX+1 AIF (&IX LE N'&SYSLIST).USRLOOP .* &USREND(&NUMGRPS) SETA &NUMUSRS .* MEND * MACRO &LAB GRPTAB GBLC &GROUPS(500),&USERS(500) GBLA &NUMGRPS,&NUMUSRS,&USRBEG(500),&USREND(500) .* LCLA &GIX,&UIX LCLA &I1,&I2,&N LCLC &C,&G1,&G2 .* &GROUPS(&NUMGRPS+1) SETC '0' .* .* - SORT -------------------------------------------------------- .* &I1 SETA 1 .SORT1 ANOP &I2 SETA &I1+1 .SORT2 ANOP &G1 SETC '&GROUPS(&I1)'.' ' &G1 SETC '&G1'(1,8) &G2 SETC '&GROUPS(&I2)'.' ' &G2 SETC '&G2'(1,8) AIF ('&G1' LE '&G2').NOSWAP &C SETC '&GROUPS(&I1)' &GROUPS(&I1) SETC '&GROUPS(&I2)' &GROUPS(&I2) SETC '&C' &N SETA &USRBEG(&I1) &USRBEG(&I1) SETA &USRBEG(&I2) &USRBEG(&I2) SETA &N &N SETA &USREND(&I1) &USREND(&I1) SETA &USREND(&I2) &USREND(&I2) SETA &N .NOSWAP ANOP &I2 SETA &I2+1 AIF (&I2 LE &NUMGRPS).SORT2 &I1 SETA &I1+1 AIF (&I1 LT &NUMGRPS).SORT1 .* .* - GENERATE ---------------------------------------------------- .* &GIX SETA 1 .GRPLOOP ANOP &GROUPS(&GIX) DC A(&GROUPS(&GIX+1)) DC AL2(&USREND(&GIX)-&USRBEG(&GIX)+1) &UIX SETA &USRBEG(&GIX) .USRLOOP ANOP DC CL8'&USERS(&UIX)' &UIX SETA &UIX+1 AIF (&UIX LE &USREND(&GIX)).USRLOOP .* &GIX SETA &GIX+1 AIF (&GIX LE &NUMGRPS).GRPLOOP .* MEND * TESTPROG CSECT * PROD1 GRP PRODID1,PRODID2 GROUP1 GRP GRP1ID1,GRP1ID2,GRP1ID3 PROD2 GRP PRODID1,PRODID2 TEST2 GRP TESTID1,TESTID2,TESTID3 GROUP2 GRP GRP1ID1,GRP1ID2,GRP1ID3 TEST1 GRP TESTID1,TESTID2,TESTID3 $GRP GRP K001214,K001238,K003142,K003208,K003385,TLEAD01, + TZ00035,TZ00056,TZ00061,TZ00529,T031682,T042407, + T045022,T046726,T047542,T056131,T056313,T057345, + T059608,T060979,T061753,T065238,T065361,T067636, + T068437,T071219,T072918,T075851,T077911,T078676, + T078999,T079290,T079829,T081658,T081897,T083056, + T083239,T084039,T085210,T087556,T088009,T088530, + T088532,T088583,T088740,T092728,T092738,T093433, + T093897,T094643,T095122,T095507,T095556,T096058, + T096148,T096199,T096255,T096518,T097282,T097579, + T097617,T097623,T098914,T099268,T099301,T100052 GRPTAB * END CONFIDENTIALITY NOTICE: This electronic transmission (including any accompanying attachments) is intended solely for its authorized recipient(s), and may contain confidential and/or legally privileged information. If you are not an intended recipient, or responsible for delivering some or all of this transmission to an intended recipient, be aware that any review, copying, printing, distribution, use or disclosure of the contents of this message is strictly prohibited. If you have received this electronic message in error, please contact us immediately by electronic mail at [EMAIL PROTECTED] or notify us immediately by telephone at 1-800-345-2021 or 816-531-5575 and destroy the original and all copies of this transmission (including any attachments). Thank you. ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [EMAIL PROTECTED] with the message: GET IBM-MAIN INFO Search the archives at http://bama.ua.edu/archives/ibm-main.html