<?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: Add sequence number and sequence number should get change with employee id change in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811878#M320282</link>
    <description>&lt;P&gt;Can we do this same operation in proc sql step, without using data step?&lt;/P&gt;</description>
    <pubDate>Fri, 06 May 2022 14:53:40 GMT</pubDate>
    <dc:creator>gahlot1999</dc:creator>
    <dc:date>2022-05-06T14:53:40Z</dc:date>
    <item>
      <title>Add sequence number and sequence number should get change with employee id change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811873#M320278</link>
      <description>&lt;P&gt;I want to add SEQNUM variable in below dataset and I want numbering to get re-started from 1 as soon as EMPID changes....means for first 8 record SEQNUM should have normal....1, 2, 3...8 but for 9th record EMPID changed then it should have again 1, 2, etc. Like this for entire table.&lt;/P&gt;&lt;P&gt;Any easy way to do this.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;I want to use proc sql only.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Current Dataset&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="gahlot1999_0-1651848289270.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71189i94977BC54EE13655/image-size/medium?v=v2&amp;amp;px=400" role="button" title="gahlot1999_0-1651848289270.png" alt="gahlot1999_0-1651848289270.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 14:48:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811873#M320278</guid>
      <dc:creator>gahlot1999</dc:creator>
      <dc:date>2022-05-06T14:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: Add sequence number and sequence number should get change with employee id change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811876#M320280</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;
by empid;
if first.empid
then seqnum = 1;
else seqnum + 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 May 2022 14:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811876#M320280</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-06T14:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Add sequence number and sequence number should get change with employee id change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811878#M320282</link>
      <description>&lt;P&gt;Can we do this same operation in proc sql step, without using data step?&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 14:53:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811878#M320282</guid>
      <dc:creator>gahlot1999</dc:creator>
      <dc:date>2022-05-06T14:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Add sequence number and sequence number should get change with employee id change</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811884#M320287</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/424399"&gt;@gahlot1999&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Can we do this same operation in proc sql step, without using data step?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Basically, no. SQL has no concept of sequence. There are methods to trick SQL into doing this, but they often rely on the use of undocumented (and therefore unreliable and dangerous) features. Apart from being (much) less performant than a data step.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Maxim 14: Use the Right Tool.&lt;/P&gt;</description>
      <pubDate>Fri, 06 May 2022 15:03:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Add-sequence-number-and-sequence-number-should-get-change-with/m-p/811884#M320287</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-05-06T15:03:45Z</dc:date>
    </item>
  </channel>
</rss>

