<?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 How to specify the order of by groups? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38702#M9950</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There might be a more direct method I can't think of at the moment, but you can always create an informat, apply it, and then use it as your by variable.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp; invalue $names&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'Henry'=1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'Alice'=2&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'James'=3&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'Jane'=4&lt;/P&gt;&lt;P&gt;&amp;nbsp; other=5;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sortnames=input(name,$names.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by sortnames;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=test (&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop=name rename=(sortnames=name));&lt;/P&gt;&lt;P&gt;&amp;nbsp; by name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 31 Oct 2011 20:05:42 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2011-10-31T20:05:42Z</dc:date>
    <item>
      <title>How to specify the order of by groups?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38701#M9949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some data that I would like to print or plot.&amp;nbsp; I would like the output grouped by a certain variable.&amp;nbsp; I can do this like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;proc print; by source;&lt;/P&gt;&lt;P&gt;proc means; by source;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my example source can be a single letter 'A', 'B', 'C', or 'D'.&amp;nbsp; I would like to specify the order of the groups.&amp;nbsp; I don't want it to be&lt;/P&gt;&lt;P&gt;alphabetical.&amp;nbsp; I might want the order to be 'C', 'B', 'D', 'A'.&amp;nbsp; Is there a way to do this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 19:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38701#M9949</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-10-31T19:49:56Z</dc:date>
    </item>
    <item>
      <title>How to specify the order of by groups?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38702#M9950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There might be a more direct method I can't think of at the moment, but you can always create an informat, apply it, and then use it as your by variable.&amp;nbsp; e.g.:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp; invalue $names&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'Henry'=1&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'Alice'=2&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'James'=3&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'Jane'=4&lt;/P&gt;&lt;P&gt;&amp;nbsp; other=5;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set sashelp.class;&lt;/P&gt;&lt;P&gt;&amp;nbsp; sortnames=input(name,$names.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by sortnames;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=test (&lt;/P&gt;&lt;P&gt;&amp;nbsp; drop=name rename=(sortnames=name));&lt;/P&gt;&lt;P&gt;&amp;nbsp; by name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 31 Oct 2011 20:05:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38702#M9950</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2011-10-31T20:05:42Z</dc:date>
    </item>
    <item>
      <title>How to specify the order of by groups?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38703#M9951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Art. it should be&lt;/P&gt;&lt;P&gt;proc format;&lt;/P&gt;&lt;P&gt;&amp;nbsp; invalue names&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not include Dollar sign because it is numeric informat not character.&lt;/P&gt;&lt;P&gt;I know SAS passed this fragment code. But I recommend to not use $.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&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>Tue, 01 Nov 2011 05:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38703#M9951</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-11-01T05:54:41Z</dc:date>
    </item>
    <item>
      <title>How to specify the order of by groups?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38704#M9952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Art.&amp;nbsp; However, the output of your example includes name=1, name=2, etc.&amp;nbsp; Is there a way to show the original names in the output instead of the value we are using to specify their order?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 Nov 2011 20:20:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38704#M9952</guid>
      <dc:creator>WesBarris</dc:creator>
      <dc:date>2011-11-01T20:20:06Z</dc:date>
    </item>
    <item>
      <title>How to specify the order of by groups?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38705#M9953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; I don't know about "instead of", but I do know how to get "in addition to."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by sortnames name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc print data=test ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by sortnames name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This should at least put both in the byvar header block.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Steve Denham&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 11:11:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38705#M9953</guid>
      <dc:creator>SteveDenham</dc:creator>
      <dc:date>2011-11-02T11:11:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to specify the order of by groups?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38706#M9954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ... never tried this before, but it appears to do what you asked ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;proc trantab table=ascii;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;replace 'C' '1' ;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;replace 'B' '2';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;replace 'D' '3';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;replace 'A' '4';&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;save table=test;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;data x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;do _n_ = 1 to 1000;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; letter = char('ABCD',rantbl(999,.25,.25,.25));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; x = ceil(1000*ranuni(999));&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;end;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;proc sort data=x sortseq=test;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;by letter;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;proc means data=x;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;by letter;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Nov 2011 14:47:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-specify-the-order-of-by-groups/m-p/38706#M9954</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2011-11-02T14:47:00Z</dc:date>
    </item>
  </channel>
</rss>

