<?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 How do I create a sort variable that restarts the count when a new subject occurs in the next rows? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845175#M334108</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to create a sort variable that restarts every new subject.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input subject $;
datalines;
001
001
002
003
003
003
004
006
007
007
008
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;desired output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hello_there_0-1668795893641.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77458iB896ED0D7A88A5D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Hello_there_0-1668795893641.png" alt="Hello_there_0-1668795893641.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Nov 2022 18:25:05 GMT</pubDate>
    <dc:creator>Hello_there</dc:creator>
    <dc:date>2022-11-18T18:25:05Z</dc:date>
    <item>
      <title>How do I create a sort variable that restarts the count when a new subject occurs in the next rows?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845175#M334108</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to create a sort variable that restarts every new subject.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input subject $;
datalines;
001
001
002
003
003
003
004
006
007
007
008
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;desired output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Hello_there_0-1668795893641.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/77458iB896ED0D7A88A5D8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Hello_there_0-1668795893641.png" alt="Hello_there_0-1668795893641.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 18:25:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845175#M334108</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-11-18T18:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a sort variable that restarts the count when a new subject occurs in the next ro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845179#M334111</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
    set have;
    by subject;
    if first.subject then sort=0;
    sort+1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Nov 2022 18:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845179#M334111</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-18T18:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a sort variable that restarts the count when a new subject occurs in the next ro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845181#M334112</link>
      <description>Thanks, PaigeMiller, this worked!</description>
      <pubDate>Fri, 18 Nov 2022 18:56:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845181#M334112</guid>
      <dc:creator>Hello_there</dc:creator>
      <dc:date>2022-11-18T18:56:36Z</dc:date>
    </item>
    <item>
      <title>Re: How do I create a sort variable that restarts the count when a new subject occurs in the next ro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845182#M334113</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by subject;
if first.subject
then sort = 1;
else sort + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use of a SUM statement causes an implied retain.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Nov 2022 18:57:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-I-create-a-sort-variable-that-restarts-the-count-when-a/m-p/845182#M334113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-18T18:57:24Z</dc:date>
    </item>
  </channel>
</rss>

