<?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 proc transpose ERROR: Data set WORK.DIAGS is not sorted in ascending sequence. The current BY in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-ERROR-Data-set-WORK-DIAGS-is-not-sorted-in/m-p/848894#M335629</link>
    <description>&lt;P&gt;code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data diags;&lt;BR /&gt;set nicecode.diag;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc transpose data=diags out=work.d(keep=clm_no diag1-diag25) prefix=diag;&lt;BR /&gt;by clm_no ;&lt;BR /&gt;id seq_no ;&lt;BR /&gt;var code;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By running this code I got below error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="slavany7_0-1670681003562.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78276iFB3EBF5D2BEDF188/image-size/medium?v=v2&amp;amp;px=400" role="button" title="slavany7_0-1670681003562.png" alt="slavany7_0-1670681003562.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So I modified the code as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data diags;&lt;BR /&gt;set diag;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data = diags;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by clm_no;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=diags out=d(keep=clm_no diag1-diag25) prefix=diag;&lt;BR /&gt;id seq_no ;&lt;BR /&gt;var code;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I got below Error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="slavany7_1-1670681157894.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78277iC1B7E9508C872AC8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="slavany7_1-1670681157894.png" alt="slavany7_1-1670681157894.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the diag Table :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="slavany7_3-1670681390675.png" style="width: 257px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78279iCED436FD28BE71D3/image-dimensions/257x67?v=v2" width="257" height="67" role="button" title="slavany7_3-1670681390675.png" alt="slavany7_3-1670681390675.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;total record counts in diag table - 585546644&lt;/P&gt;</description>
    <pubDate>Sat, 10 Dec 2022 14:15:43 GMT</pubDate>
    <dc:creator>qwerty12</dc:creator>
    <dc:date>2022-12-10T14:15:43Z</dc:date>
    <item>
      <title>proc transpose ERROR: Data set WORK.DIAGS is not sorted in ascending sequence. The current BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-ERROR-Data-set-WORK-DIAGS-is-not-sorted-in/m-p/848894#M335629</link>
      <description>&lt;P&gt;code :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data diags;&lt;BR /&gt;set nicecode.diag;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc transpose data=diags out=work.d(keep=clm_no diag1-diag25) prefix=diag;&lt;BR /&gt;by clm_no ;&lt;BR /&gt;id seq_no ;&lt;BR /&gt;var code;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By running this code I got below error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="slavany7_0-1670681003562.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78276iFB3EBF5D2BEDF188/image-size/medium?v=v2&amp;amp;px=400" role="button" title="slavany7_0-1670681003562.png" alt="slavany7_0-1670681003562.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So I modified the code as below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data diags;&lt;BR /&gt;set diag;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sort data = diags;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;by clm_no;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;proc transpose data=diags out=d(keep=clm_no diag1-diag25) prefix=diag;&lt;BR /&gt;id seq_no ;&lt;BR /&gt;var code;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I got below Error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="slavany7_1-1670681157894.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78277iC1B7E9508C872AC8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="slavany7_1-1670681157894.png" alt="slavany7_1-1670681157894.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the diag Table :&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="slavany7_3-1670681390675.png" style="width: 257px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/78279iCED436FD28BE71D3/image-dimensions/257x67?v=v2" width="257" height="67" role="button" title="slavany7_3-1670681390675.png" alt="slavany7_3-1670681390675.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;total record counts in diag table - 585546644&lt;/P&gt;</description>
      <pubDate>Sat, 10 Dec 2022 14:15:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-ERROR-Data-set-WORK-DIAGS-is-not-sorted-in/m-p/848894#M335629</guid>
      <dc:creator>qwerty12</dc:creator>
      <dc:date>2022-12-10T14:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose ERROR: Data set WORK.DIAGS is not sorted in ascending sequence. The current BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-ERROR-Data-set-WORK-DIAGS-is-not-sorted-in/m-p/848896#M335631</link>
      <description>&lt;P&gt;It looks like you have duplicate values for the ID variable, seq_no, in your input dataset. You should be able to resolve this issue by using the nodupkey option on your PROC SORT step, as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data = diags nodupkey;&lt;BR /&gt;by clm_no;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 10 Dec 2022 14:24:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-ERROR-Data-set-WORK-DIAGS-is-not-sorted-in/m-p/848896#M335631</guid>
      <dc:creator>ger15xxhcker</dc:creator>
      <dc:date>2022-12-10T14:24:55Z</dc:date>
    </item>
    <item>
      <title>Re: proc transpose ERROR: Data set WORK.DIAGS is not sorted in ascending sequence. The current BY</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-transpose-ERROR-Data-set-WORK-DIAGS-is-not-sorted-in/m-p/848955#M335656</link>
      <description>&lt;P&gt;You second proc transpose code does not have the BY clm_no. Why did you remove that after sorting by that variable?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have any duplicates of ID variables when there is no BY grouping then that is expected. If you have duplicate values of ID variables within a BY group, i.e. value of Clm_no, then that would also be expected. The ID variables are used to create names for output variables. SAS will not allow a data set to have a variable name duplicated. So if the value if an ID variable, or combination of Id variables. occurs, you get this error because the requested variable names are invalid.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since this is a matter of values of variables then a picture of variable types isn't particularly helpful. You would need to provide an actual example of data values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: you can test if you might have this sort of repeated Id value but using Proc freq code:&lt;/P&gt;
&lt;PRE&gt;Proc freq data=diags;
   table clm_no * seq_no /missing list;
run;&lt;/PRE&gt;
&lt;P&gt;If you see a count of 2 or greater for any clm_no * seq_no combination then you need to do something else that the Transpose code you show.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Dec 2022 02:54:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-transpose-ERROR-Data-set-WORK-DIAGS-is-not-sorted-in/m-p/848955#M335656</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-12-11T02:54:59Z</dc:date>
    </item>
  </channel>
</rss>

