<?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: How to output a variable containing numeric part in ascending order? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-a-variable-containing-numeric-part-in-ascending/m-p/232514#M42383</link>
    <description>&lt;P&gt;This is a common issue with character variables. You have&amp;nbsp; couple of options. One is the be very conscious of using Group01 instead of Group1 though that may be difficulate to use as an approach if you don't know ahead of time that you're going to need Group0001 ...&lt;/P&gt;
&lt;P&gt;The next to&amp;nbsp;create your summaries into a data set. Then use proc sort with the SORTSEQ option Numeric_collation=On&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have sortseq=linguistic(numeric_collation='ON'); by group;run;&lt;/P&gt;
&lt;P&gt;and then print.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if any of the report procedures directly support the option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The other approach is create a variable that always sorts in the order you want and then use a custom display format to diplay the desired value. Some times the new variable is easiest to create with a custom informat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format ;&lt;/P&gt;
&lt;P&gt;invalue group&lt;/P&gt;
&lt;P&gt;"group1" = 1&lt;/P&gt;
&lt;P&gt;"group2" = 2&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;"group10" = 10;&lt;/P&gt;
&lt;P&gt;value group&lt;/P&gt;
&lt;P&gt;1 = "group1"&lt;/P&gt;
&lt;P&gt;2 = "group2"&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;10= "group10"&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; newgroup = input(group,group.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; format newgroup group.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=want ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class newgroup /order=unformatted;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var analysisvar;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 30 Oct 2015 20:52:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-10-30T20:52:43Z</dc:date>
    <item>
      <title>How to output a variable containing numeric part in ascending order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-a-variable-containing-numeric-part-in-ascending/m-p/232511#M42381</link>
      <description>&lt;P&gt;Generally I want to use "class group;" to output means for&amp;nbsp;"group1, group2, ....group10" like:&lt;/P&gt;&lt;P&gt;Group &amp;nbsp; &amp;nbsp; &amp;nbsp;mean &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;group1 &amp;nbsp; &amp;nbsp; &amp;nbsp; ..&lt;/P&gt;&lt;P&gt;group2 &amp;nbsp; &amp;nbsp; &amp;nbsp;..&lt;/P&gt;&lt;P&gt;... &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ..&lt;/P&gt;&lt;P&gt;group9 &amp;nbsp; &amp;nbsp; &amp;nbsp;..&lt;/P&gt;&lt;P&gt;group10 &amp;nbsp; &amp;nbsp;..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;however, if using just "class group;", the output is like:&lt;/P&gt;&lt;P&gt;Group &amp;nbsp; &amp;nbsp; &amp;nbsp;Mean&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group1 &amp;nbsp; &amp;nbsp; &amp;nbsp; ..&lt;/P&gt;&lt;P&gt;group10&amp;nbsp; &amp;nbsp; &amp;nbsp;..&lt;/P&gt;&lt;P&gt;... &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;..&lt;/P&gt;&lt;P&gt;group8 &amp;nbsp; &amp;nbsp; &amp;nbsp; ..&lt;/P&gt;&lt;P&gt;group9 &amp;nbsp; &amp;nbsp; &amp;nbsp; ..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group10 was not output at the bottom, but instead, it showed after group1.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can it be coded so that group10 is at the bottom. thank you very much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 20:23:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-a-variable-containing-numeric-part-in-ascending/m-p/232511#M42381</guid>
      <dc:creator>lifelearner2015</dc:creator>
      <dc:date>2015-10-30T20:23:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a variable containing numeric part in ascending order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-a-variable-containing-numeric-part-in-ascending/m-p/232514#M42383</link>
      <description>&lt;P&gt;This is a common issue with character variables. You have&amp;nbsp; couple of options. One is the be very conscious of using Group01 instead of Group1 though that may be difficulate to use as an approach if you don't know ahead of time that you're going to need Group0001 ...&lt;/P&gt;
&lt;P&gt;The next to&amp;nbsp;create your summaries into a data set. Then use proc sort with the SORTSEQ option Numeric_collation=On&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=have sortseq=linguistic(numeric_collation='ON'); by group;run;&lt;/P&gt;
&lt;P&gt;and then print.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm not sure if any of the report procedures directly support the option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The other approach is create a variable that always sorts in the order you want and then use a custom display format to diplay the desired value. Some times the new variable is easiest to create with a custom informat:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc format ;&lt;/P&gt;
&lt;P&gt;invalue group&lt;/P&gt;
&lt;P&gt;"group1" = 1&lt;/P&gt;
&lt;P&gt;"group2" = 2&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;"group10" = 10;&lt;/P&gt;
&lt;P&gt;value group&lt;/P&gt;
&lt;P&gt;1 = "group1"&lt;/P&gt;
&lt;P&gt;2 = "group2"&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;10= "group10"&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; newgroup = input(group,group.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; format newgroup group.;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc means data=want ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; class newgroup /order=unformatted;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var analysisvar;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2015 20:52:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-a-variable-containing-numeric-part-in-ascending/m-p/232514#M42383</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-10-30T20:52:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to output a variable containing numeric part in ascending order?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-output-a-variable-containing-numeric-part-in-ascending/m-p/232516#M42384</link>
      <description>&lt;P&gt;many thanks! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;LI-SPOILER&gt;&amp;nbsp;&lt;/LI-SPOILER&gt;</description>
      <pubDate>Fri, 30 Oct 2015 20:53:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-output-a-variable-containing-numeric-part-in-ascending/m-p/232516#M42384</guid>
      <dc:creator>lifelearner2015</dc:creator>
      <dc:date>2015-10-30T20:53:28Z</dc:date>
    </item>
  </channel>
</rss>

