<?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: calculate seq number within group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/calculate-seq-number-within-group/m-p/981136#M379037</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input group x z seq;
cards;
111 10 20 1
111 10 20 1
111 30 40 2
222 10 20 1  
222 10 20 1
333 40 50 1
444 15 20 1 
444 15 20 1
444 15 20 1
444 30 50 2
444 60 80 3
444 60 80 3
;
Run;
data want;
 set have;
 by group x z notsorted;
 if first.group then want_seq=0;
 want_seq+first.z;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sat, 20 Dec 2025 08:28:46 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-12-20T08:28:46Z</dc:date>
    <item>
      <title>calculate seq number within group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-seq-number-within-group/m-p/981135#M379036</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to create serial number within each group by following rule:&lt;/P&gt;
&lt;P&gt;Wanted calculate column is called seq.&lt;/P&gt;
&lt;P&gt;How can I calculate it please from have data set?&lt;/P&gt;
&lt;P&gt;The rule is - for each group we calculate seq numbers but IF values of X,Z are same between rows then rows get same seq number&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input group x z seq;
cards;
111 10 20 1
111 10 20 1
111 30 40 2
222 10 20 1  
222 10 20 1
333 40 50 1
444 15 20 1 
444 15 20 1
444 15 20 1
444 30 50 2
444 60 80 3
444 60 80 3
;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Dec 2025 07:34:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-seq-number-within-group/m-p/981135#M379036</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2025-12-20T07:34:34Z</dc:date>
    </item>
    <item>
      <title>Re: calculate seq number within group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/calculate-seq-number-within-group/m-p/981136#M379037</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input group x z seq;
cards;
111 10 20 1
111 10 20 1
111 30 40 2
222 10 20 1  
222 10 20 1
333 40 50 1
444 15 20 1 
444 15 20 1
444 15 20 1
444 30 50 2
444 60 80 3
444 60 80 3
;
Run;
data want;
 set have;
 by group x z notsorted;
 if first.group then want_seq=0;
 want_seq+first.z;
 run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 20 Dec 2025 08:28:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/calculate-seq-number-within-group/m-p/981136#M379037</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-12-20T08:28:46Z</dc:date>
    </item>
  </channel>
</rss>

