<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to assign sequence number group wise with every five records in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884187#M349284</link>
    <description>&lt;P&gt;I cannot understand what your restriction is.&lt;/P&gt;
&lt;P&gt;Do you want to COUNT the existing groups?&lt;/P&gt;
&lt;P&gt;Or do you want to CREATE the groups?&lt;/P&gt;
&lt;P&gt;Or is it some combination of the two?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your original example just set the first 5 observations to SEQ=1, the next 5 to SEQ=2 etc.&amp;nbsp; So it was creating groups by simply assigning the first 5 to the first group, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If instead you want to NUMBER the groups that exist then just use BY group processing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example this will generate a new SEQ number of for each unique SEX*AGE combination.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by sex age;
  seq + first.age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the data is already grouped, but not necessarily sorted then use the NOTSORTED keyword on the BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or perhaps you want to split the groups into subgroups of 5 in a row by restarting the seq numbers from one when a new group starts?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   seq+1;
   do subseq=1 to 5 until(last.age);
        set have ;
        by sex age;
        output;
   end;
   if last.sex then seq=0;
run;   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please share data as text, not photographs.&amp;nbsp; Preferable as data steps that can be used to recreate the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jul 2023 13:34:40 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-07-10T13:34:40Z</dc:date>
    <item>
      <title>how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884177#M349279</link>
      <description>&lt;P&gt;/**how to assign sequence number every 5 records with group wise(sex, descending age)**/&lt;/P&gt;
&lt;P&gt;name sex age height weight seq&lt;BR /&gt;Janet F 15 62.5 112.5 1&lt;BR /&gt;Mary F 15 66.5 112 1&lt;BR /&gt;Carol F 14 62.8 102.5 1&lt;BR /&gt;Judy F 14 64.3 90 1&lt;BR /&gt;&lt;STRONG&gt;Alice F 13 56.5 84 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Barbara F 13 65.3 98 2&lt;/STRONG&gt;&lt;BR /&gt;Jane F 12 59.8 84.5 2&lt;BR /&gt;Louise F 12 56.3 77 2&lt;BR /&gt;Joyce F 11 51.3 50.5 2&lt;BR /&gt;Philip M 16 72 150 2&lt;BR /&gt;Ronald M 15 67 133 3&lt;BR /&gt;William M 15 66.5 112 3&lt;BR /&gt;Alfred M 14 69 112.5 3&lt;BR /&gt;Henry M 14 63.5 102.5 3&lt;BR /&gt;Jeffrey M 13 62.5 84 3&lt;BR /&gt;James M 12 57.3 83 4&lt;BR /&gt;John M 12 59 99.5 4&lt;BR /&gt;Robert M 12 64.8 128 4&lt;BR /&gt;Thomas M 11 57.5 85 4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to assign sequence number group wise sex and descending age wise with every 5 records if same group display in different sequence number have to forward to next sequence number .&lt;BR /&gt;output should be like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;name sex age height weight seq&lt;BR /&gt;Janet F 15 62.5 112.5 1&lt;BR /&gt;Mary F 15 66.5 112 1&lt;BR /&gt;Carol F 14 62.8 102.5 1&lt;BR /&gt;Judy F 14 64.3 90 1&lt;BR /&gt;&lt;STRONG&gt;Alice F 13 56.5 84 2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Barbara F 13 65.3 98 2&lt;/STRONG&gt;&lt;BR /&gt;Jane F 12 59.8 84.5 2&lt;BR /&gt;Louise F 12 56.3 77 2&lt;BR /&gt;Joyce F 11 51.3 50.5 2&lt;BR /&gt;Philip M 16 72 150 3&lt;BR /&gt;Ronald M 15 67 133 3&lt;BR /&gt;William M 15 66.5 112 3&lt;BR /&gt;Alfred M 14 69 112.5 3&lt;BR /&gt;Henry M 14 63.5 102.5 3&lt;BR /&gt;Jeffrey M 13 62.5 84 4&lt;BR /&gt;James M 12 57.3 83 4&lt;BR /&gt;John M 12 59 99.5 4&lt;BR /&gt;Robert M 12 64.8 128 4&lt;BR /&gt;Thomas M 11 57.5 85 4&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;how to do do while/do until/do loop concept?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 12:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884177#M349279</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2023-07-10T12:52:52Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884179#M349280</link>
      <description>&lt;P&gt;You could just use arithmetic.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  seq = 1 + int((_n_-1)/5);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or just count.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   seq+1;
   do subseq=1 to 5;
     set have;
     output;
   end;
   drop subseq;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jul 2023 13:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884179#M349280</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T13:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884184#M349282</link>
      <description>&lt;P&gt;Thank you for your quick response but this code not reaching for my requirement .&lt;BR /&gt;The age group should be same sequence number with in sex group&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please find screen shot I have set the data in sex, descending order after that if i apply the your code/logic it's giving every five records one number but I need&amp;nbsp;&lt;BR /&gt;if same group split into two sequence number the first record/first few records forward to sequence number.&lt;/P&gt;
&lt;P&gt;for example:&lt;/P&gt;
&lt;P&gt;5th and 6th records are same sex and age groups but sequence numbers are wrong . Here 5th record sequence number should be 2nd&lt;/P&gt;
&lt;DIV id="tinyMceEditorthanikondharish_0" class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="thanikondharish_1-1688995340275.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/85692iF1E23E895E7965D4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="thanikondharish_1-1688995340275.png" alt="thanikondharish_1-1688995340275.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 13:23:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884184#M349282</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2023-07-10T13:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884187#M349284</link>
      <description>&lt;P&gt;I cannot understand what your restriction is.&lt;/P&gt;
&lt;P&gt;Do you want to COUNT the existing groups?&lt;/P&gt;
&lt;P&gt;Or do you want to CREATE the groups?&lt;/P&gt;
&lt;P&gt;Or is it some combination of the two?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your original example just set the first 5 observations to SEQ=1, the next 5 to SEQ=2 etc.&amp;nbsp; So it was creating groups by simply assigning the first 5 to the first group, etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If instead you want to NUMBER the groups that exist then just use BY group processing.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example this will generate a new SEQ number of for each unique SEX*AGE combination.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by sex age;
  seq + first.age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If the data is already grouped, but not necessarily sorted then use the NOTSORTED keyword on the BY statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or perhaps you want to split the groups into subgroups of 5 in a row by restarting the seq numbers from one when a new group starts?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
   seq+1;
   do subseq=1 to 5 until(last.age);
        set have ;
        by sex age;
        output;
   end;
   if last.sex then seq=0;
run;   &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please share data as text, not photographs.&amp;nbsp; Preferable as data steps that can be used to recreate the data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 13:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884187#M349284</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T13:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884188#M349285</link>
      <description>&lt;P&gt;In your example:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;name sex age height weight seq&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Janet F 15 62.5 112.5 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mary F 15 66.5 112 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Carol F 14 62.8 102.5 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Judy F 14 64.3 90 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;STRONG&gt;Alice F 13 56.5 84 2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;Barbara F 13 65.3 98 2&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Jane F 12 59.8 84.5 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Louise F 12 56.3 77 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Joyce F 11 51.3 50.5 2&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;you change to seq=2 after only 4 observations, but then keep seq=2 for 5 observations. So do you increment&amp;nbsp;&lt;EM&gt;with the 5th&lt;/EM&gt;, or&amp;nbsp;&lt;EM&gt;after 5&lt;/EM&gt;?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 13:34:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884188#M349285</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-07-10T13:34:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884192#M349287</link>
      <description>&lt;P&gt;simple one like what I am trying to say we need to generate sequence number every 5 records .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;5 record(nothing but seq=1) &lt;STRONG&gt;=&lt;/STRONG&gt;&amp;nbsp;6th record(seq=2)&amp;nbsp; both are (5th,6th records) same&amp;nbsp; unique sex*age groups . So here 5th record also sequence number should be '2'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Outpu should be like(see below output):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;name sex age height weight seq&lt;BR /&gt;Janet F 15 62.5 112.5 1&lt;BR /&gt;Mary F 15 66.5 112 1&lt;BR /&gt;Carol F 14 62.8 102.5 1&lt;BR /&gt;Judy F 14 64.3 90 1&lt;BR /&gt;Alice F 13 56.5 84 2&lt;BR /&gt;Barbara F 13 65.3 98 2&lt;BR /&gt;Jane F 12 59.8 84.5 2&lt;BR /&gt;Louise F 12 56.3 77 2&lt;BR /&gt;Joyce F 11 51.3 50.5 2&lt;BR /&gt;Philip M 16 72 150 3&lt;BR /&gt;Ronald M 15 67 133 3&lt;BR /&gt;William M 15 66.5 112 3&lt;BR /&gt;Alfred M 14 69 112.5 3&lt;BR /&gt;Henry M 14 63.5 102.5 3&lt;BR /&gt;Jeffrey M 13 62.5 84 4&lt;BR /&gt;James M 12 57.3 83 4&lt;BR /&gt;John M 12 59 99.5 4&lt;BR /&gt;Robert M 12 64.8 128 4&lt;BR /&gt;Thomas M 11 57.5 85 4&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 13:44:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884192#M349287</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2023-07-10T13:44:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884194#M349289</link>
      <description>&lt;P&gt;Let me see if I can translate that so you can confirm your intention.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have the records in SEX*AGE groups.&amp;nbsp; Put those groups into combinations of no more than 5 observations.&amp;nbsp; &amp;nbsp;In this example the first 5 records include 3 groups of 2 member each.&amp;nbsp; So you just want the first 4 to be in the first new group (seq).&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This raises a big question:&amp;nbsp; What do you do when one of the groups has more than 5 members already?&amp;nbsp; Does that new grouping (seq) include more than 5 in that case?&amp;nbsp; Or does the group get split into across two (or more) of the new SEQ groupings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let's assume you want any large group to be its own seq.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data want;
  do n=1 by 1 until(last.age);
    set have;
    by sex age notsorted;
  end;
  if (total+n) &amp;gt; 5 or _n_=1 then do; 
     seq+1;
     total=n;
  end;
  else total+n;
  do n=1 to n ;
    set have;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    n    name       sex    age    height    weight    seq_want    total    seq

  1    1    Janet       F      15     62.5      112.5        1         2       1
  2    2    Mary        F      15     66.5      112.0        1         2       1
  3    1    Carol       F      14     62.8      102.5        1         4       1
  4    2    Judy        F      14     64.3       90.0        1         4       1
  5    1    Alice       F      13     56.5       84.0        2         2       2
  6    2    Barbara     F      13     65.3       98.0        2         2       2
  7    1    Jane        F      12     59.8       84.5        2         4       2
  8    2    Louise      F      12     56.3       77.0        2         4       2
  9    1    Joyce       F      11     51.3       50.5        2         5       2
 10    1    Philip      M      16     72.0      150.0        3         1       3
 11    1    Ronald      M      15     67.0      133.0        3         3       3
 12    2    William     M      15     66.5      112.0        3         3       3
 13    1    Alfred      M      14     69.0      112.5        3         5       3
 14    2    Henry       M      14     63.5      102.5        3         5       3
 15    1    Jeffrey     M      13     62.5       84.0        4         1       4
 16    1    James       M      12     57.3       83.0        4         4       4
 17    2    John        M      12     59.0       99.5        4         4       4
 18    3    Robert      M      12     64.8      128.0        4         4       4
 19    1    Thomas      M      11     57.5       85.0        4         5       4
&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884194#M349289</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T14:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884195#M349290</link>
      <description>&lt;P&gt;Thank you for your response.&lt;BR /&gt;If unique groups having more than 5 records for example 8 records here I consider every 8 observations with unique groups sequence number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5 is just sample/example&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884195#M349290</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2023-07-10T14:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884196#M349291</link>
      <description>&lt;P&gt;As of now below code is working.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="language-sas"&gt;&lt;CODE&gt;data want;
  do n=1 by 1 until(last.age);
    set have;
    by sex age notsorted;
  end;
  if (total+n) &amp;gt; 5 or _n_=1 then do; 
     seq+1;
     total=n;
  end;
  else total+n;
  do n=1 to n ;
    set have;
    output;
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884196#M349291</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2023-07-10T14:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884199#M349293</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/209685"&gt;@thanikondharish&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for your response.&lt;BR /&gt;If unique groups having more than 5 records for example 8 records here I consider every 8 observations with unique groups sequence number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;5 is just sample/example&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;In that case you need to process the dataset twice.&amp;nbsp; Once to find the maximum group size.&amp;nbsp; The second to make the new groups.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But why did you use 5 for your example instead of the actual maximum of 3?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884199#M349293</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T14:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884210#M349298</link>
      <description>&lt;P&gt;Could you please explain me how the code/program works?&lt;BR /&gt;Could you please explain me step by step?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 15:49:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884210#M349298</guid>
      <dc:creator>thanikondharish</dc:creator>
      <dc:date>2023-07-10T15:49:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to assign sequence number group wise with every five records</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884212#M349300</link>
      <description>&lt;P&gt;Count how many observations are in the group.&lt;/P&gt;
&lt;P&gt;Does adding that many observations make the size of the current SEQ group exceed the limit?&amp;nbsp; If so start a new SEQ group.&lt;/P&gt;
&lt;P&gt;Re-read the observations in the group and write them back out so that all of the observations in the group have the new SEQ variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is just a twist on the basic double DOW loop.&amp;nbsp;&amp;nbsp;&lt;A href="https://www.google.com/search?q=%40sas.com+dow+loop" target="_blank" rel="noopener"&gt;https://www.google.com/search?q=%40sas.com+dow+loop&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 15:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-assign-sequence-number-group-wise-with-every-five-records/m-p/884212#M349300</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-07-10T15:57:32Z</dc:date>
    </item>
  </channel>
</rss>

