<?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: Proc sort _ Position of variables in &amp;quot;BY&amp;quot; statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914631#M40948</link>
    <description>Got it..&lt;BR /&gt;Thankyou....</description>
    <pubDate>Tue, 06 Feb 2024 05:12:18 GMT</pubDate>
    <dc:creator>AthiraThulasi</dc:creator>
    <dc:date>2024-02-06T05:12:18Z</dc:date>
    <item>
      <title>Proc sort _ Position of variables in "BY" statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914578#M40944</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a new SAS user. Pls help me understand the difference in the following code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the first code - rbc and wbc written right after "BY" statement are sorted in the ascending order.&lt;/P&gt;&lt;P&gt;In the second code -&amp;nbsp;rbc and cholesterol written after wbc is not sorted in ascending order. Why is that?&lt;/P&gt;&lt;P&gt;As per my understanding, variables in "BY" statement are default sorted in ascending order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT DATA = blood OUT = sorted_blood;&lt;BR /&gt;BY rbc cholesterol DESCENDING wbc;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="IMG_8954.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93276iB2D606387CB856C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="IMG_8954.png" alt="IMG_8954.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SORT DATA = blood OUT = sorted_blood;&lt;BR /&gt;BY DESCENDING wbc rbc cholesterol;&lt;BR /&gt;run;&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="IMG_0089.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93277i01D097B62EDF9BB6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="IMG_0089.png" alt="IMG_0089.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Feb 2024 21:30:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914578#M40944</guid>
      <dc:creator>AthiraThulasi</dc:creator>
      <dc:date>2024-02-05T21:30:01Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort _ Position of variables in "BY" statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914613#M40946</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;As per my understanding, variables in "BY" statement are default sorted in ascending order.&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's correct.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;In the second code -&amp;nbsp;rbc and cholesterol written after wbc is not sorted in ascending order. Why is that?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Your sort is:&amp;nbsp;&lt;SPAN&gt;BY DESCENDING wbc rbc cholesterol;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The first level of sorting is: DESCENDING wbc&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Within the same value for WBC rows then get sorted by ascending rbc and then within the same value of rbc they get sorted by ascending cholesterol.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To "see" that the sorting also works for 3rd level cholesterol you would need to find multiple rows in your source data with identical values for wbc and rbc.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you look at your data then you'll see that it's sorted as requested.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1707180198945.png" style="width: 581px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93285iE380EDB5F1B5CB35/image-dimensions/581x233?v=v2" width="581" height="233" role="button" title="Patrick_0-1707180198945.png" alt="Patrick_0-1707180198945.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 00:43:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914613#M40946</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2024-02-06T00:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort _ Position of variables in "BY" statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914618#M40947</link>
      <description>&lt;P&gt;All the by variables are sorted in ascending order by default. Variables to be sorted by descending order should be preceded by the word descending, which is what you are doing in your code.&lt;BR /&gt;&lt;BR /&gt;You are sorting the whole table by:&lt;BR /&gt;RBC in ascending order&lt;BR /&gt;Then, by Cholesterol in Ascending Order.&lt;/P&gt;&lt;P&gt;And finally, by WBC in Descending order due to the keyword 'descending' placed before WBC.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sort applies to variables in the order listed under BY variable. If you study the rows with identical data points, you will understand.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Second example:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="rvikram_0-1707184330024.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/93286i155B33B3B653170D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="rvikram_0-1707184330024.png" alt="rvikram_0-1707184330024.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Feb 2024 01:52:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914618#M40947</guid>
      <dc:creator>rvikram</dc:creator>
      <dc:date>2024-02-06T01:52:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort _ Position of variables in "BY" statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914631#M40948</link>
      <description>Got it..&lt;BR /&gt;Thankyou....</description>
      <pubDate>Tue, 06 Feb 2024 05:12:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914631#M40948</guid>
      <dc:creator>AthiraThulasi</dc:creator>
      <dc:date>2024-02-06T05:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sort _ Position of variables in "BY" statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914632#M40949</link>
      <description>Got it , I checked the identical points...&lt;BR /&gt;Thanks much...</description>
      <pubDate>Tue, 06 Feb 2024 05:14:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-sort-Position-of-variables-in-quot-BY-quot-statement/m-p/914632#M40949</guid>
      <dc:creator>AthiraThulasi</dc:creator>
      <dc:date>2024-02-06T05:14:10Z</dc:date>
    </item>
  </channel>
</rss>

