<?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 sorting one group and ignoring the other in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44498#M11758</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; is it a where filter you need?&lt;/P&gt;&lt;P&gt;It can be a statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where year NE 2009 ;&lt;/P&gt;&lt;P&gt;or a data set option&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data= your_data( where=( year NE 2009 )) &lt;/P&gt;&lt;P&gt;your choice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Nov 2011 21:53:21 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2011-11-09T21:53:21Z</dc:date>
    <item>
      <title>sorting one group and ignoring the other</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44497#M11757</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How do I sort this dataset by 2010 and ignore 2009?&lt;BR /&gt;I created a proc report where year is an "across" variable and item is the group. I would like the items to be sorted based on 2010.&lt;/P&gt;&lt;P&gt;year item count&lt;BR /&gt;2009 a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;BR /&gt;2009 b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;BR /&gt;2009 c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;BR /&gt;2010 a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/P&gt;&lt;P&gt;2010 b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 15&lt;BR /&gt;2010 c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 19:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44497#M11757</guid>
      <dc:creator>gzr2mz39</dc:creator>
      <dc:date>2011-11-09T19:54:48Z</dc:date>
    </item>
    <item>
      <title>sorting one group and ignoring the other</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44498#M11758</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; is it a where filter you need?&lt;/P&gt;&lt;P&gt;It can be a statement&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where year NE 2009 ;&lt;/P&gt;&lt;P&gt;or a data set option&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data= your_data( where=( year NE 2009 )) &lt;/P&gt;&lt;P&gt;your choice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 21:53:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44498#M11758</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-11-09T21:53:21Z</dc:date>
    </item>
    <item>
      <title>sorting one group and ignoring the other</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44499#M11759</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No, I don't think so - year is across.&lt;/P&gt;&lt;P&gt;I'm not much of a proc report guy, it could probably solved there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But you could on beforehand extract 2010 data, find out your order (a rank on count in your case?). &lt;/P&gt;&lt;P&gt;Then add an ordering variable (_n_ in data step will do). And join back on your original data on item column.&lt;/P&gt;&lt;P&gt;And then, you use the new variable as a non display column, used for ordering only.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Linus&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 22:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44499#M11759</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2011-11-09T22:31:51Z</dc:date>
    </item>
    <item>
      <title>sorting one group and ignoring the other</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44500#M11760</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I don't understand your last sentence.&lt;/P&gt;&lt;P&gt;What do you want your report to look like?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2011 05:23:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44500#M11760</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-11-10T05:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: sorting one group and ignoring the other</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44501#M11761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp; I'm confused by your data and your description. Without any other information from you, PROC REPORT will order the ROWS, based on the values of the ITEM variable. So the default order for your ROWS would be A first, then B, then C.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Do you want the ROWS to be reordered based on the values for the same items in 2010???? If so, it is possible that the code below might do what you want. I changed the data for 2010, so that the final order would be something different from the PROC REPORT default of A, B, C. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cynthia&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** make some data;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** changed 2010 so that count for item C is largest;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** because PROC REPORT default order for item;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** would be A, B, C and I wanted the final order;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** to be different from the default.;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;data testyear(keep=year item count)&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ordyr(keep=item ordyr);&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; infile datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; input year item $ count;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; output testyear;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; if year = 2010 then do;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ordyr = count;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output ordyr;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; end;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;return;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;datalines;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2009 a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2009 b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 30&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2009 c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2010 a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12 &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2010 b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2010 c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 20&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2007 a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2007 b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2007 c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2008 a&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2008 b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;2008 c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** Join the two tables, so that;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** ORDYR from 2010 is joined to every year;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc sql;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; create table final as&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; select a.ordyr, b.item, b.year, b.count&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; from ordyr as a,&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; testyear as b&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; where a.item = b.item;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** Show the PROC REPORT default, versus using the ORDYR variable;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;** for ordering the rows;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html file='c:\temp\testrept.html' style=sasweb;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc report data=final nowd;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title '1) proc report default';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; column item year,count;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define item /group;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define year / across;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define count / sum;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;proc report data=final nowd;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; title '2) using ordyr variable';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; column ordyr item year,count;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define ordyr / group descending /* noprint */;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define item /group;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define year / across;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;&amp;nbsp; define count / sum;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;run;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG style="font-family: courier new,courier;"&gt;ods html close;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2011 07:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/sorting-one-group-and-ignoring-the-other/m-p/44501#M11761</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-11-10T07:09:46Z</dc:date>
    </item>
  </channel>
</rss>

