<?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: Interleaving question Sort indicator in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Interleaving-question-Sort-indicator/m-p/217256#M40014</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DATA step has the potential to destroy the sorted order.&amp;nbsp; For example, this would be a legal program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set already_sorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if amount &amp;gt; 1000 then id='ABC';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The new data set is not sorted, even though the incoming data set is sorted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you know that the sorted order is going to be maintained, you can add that as a data set option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data interleaved (sortedby=id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set a b;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you then run a PROC CONTENTS, the sort indicator will be maintained.&amp;nbsp; However, the second related indicator (VALIDATED) will not be set because SAS has not validated the sorted order. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, when you use the SORTEDBY data set option, you better be correct.&amp;nbsp; If you are wrong, the data will not be in order but subsequent PROC SORTs will be skipped.&amp;nbsp; There are ways around that, but it's better not to get into that situation in the first place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Apr 2015 15:45:34 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-04-07T15:45:34Z</dc:date>
    <item>
      <title>Interleaving question Sort indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Interleaving-question-Sort-indicator/m-p/217255#M40013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have two sorted SAS data sets and now want to interleave them together.&amp;nbsp; I am noticing after interleaving them using the same by variable that both are sorted on, the sort indicator is not retained in the resulting dataset.&amp;nbsp; Does anyone know why after interleaving these datasets the sort indicator (I'm validating using proc contents) would no longer be set ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 13:46:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Interleaving-question-Sort-indicator/m-p/217255#M40013</guid>
      <dc:creator>Tvak</dc:creator>
      <dc:date>2015-04-07T13:46:29Z</dc:date>
    </item>
    <item>
      <title>Re: Interleaving question Sort indicator</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Interleaving-question-Sort-indicator/m-p/217256#M40014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DATA step has the potential to destroy the sorted order.&amp;nbsp; For example, this would be a legal program:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data new;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set already_sorted;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if amount &amp;gt; 1000 then id='ABC';&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The new data set is not sorted, even though the incoming data set is sorted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you know that the sorted order is going to be maintained, you can add that as a data set option:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data interleaved (sortedby=id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set a b;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; by id;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you then run a PROC CONTENTS, the sort indicator will be maintained.&amp;nbsp; However, the second related indicator (VALIDATED) will not be set because SAS has not validated the sorted order. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Finally, when you use the SORTEDBY data set option, you better be correct.&amp;nbsp; If you are wrong, the data will not be in order but subsequent PROC SORTs will be skipped.&amp;nbsp; There are ways around that, but it's better not to get into that situation in the first place.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Apr 2015 15:45:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Interleaving-question-Sort-indicator/m-p/217256#M40014</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-04-07T15:45:34Z</dc:date>
    </item>
  </channel>
</rss>

