<?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: Sorting issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176805#M33851</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to split the numeric part out from the text, multiply it per the unit, then sort by that value:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table WANT (drop=WEIGHT) as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select&amp;nbsp; NAME,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case&amp;nbsp; when index(NAME,"kg")&amp;gt;0 then input(tranwrd(tranwrd(NAME,"chilli",""),"kg",""),best.) * 1000&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; else input(tranwrd(tranwrd(NAME,"chilli",""),"g",""),best.) end as WEIGHT&lt;/P&gt;&lt;P&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;&amp;nbsp; order by WEIGHT;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 May 2014 09:15:56 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2014-05-29T09:15:56Z</dc:date>
    <item>
      <title>Sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176804#M33850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am facing sorting issue in my data.So I need a solution for that.&lt;/P&gt;&lt;P&gt;the sample data is&lt;/P&gt;&lt;P&gt;data a;&lt;/P&gt;&lt;P&gt;infile datalines dlm=',';&lt;/P&gt;&lt;P&gt;input name $ 15.;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;chilli 10g&lt;/P&gt;&lt;P&gt;chilli 100g&lt;/P&gt;&lt;P&gt;chilli 15g&lt;/P&gt;&lt;P&gt;chilli 200g&lt;/P&gt;&lt;P&gt;chilli 150g&lt;/P&gt;&lt;P&gt;chilli 1kg&lt;/P&gt;&lt;P&gt;chilli 250g&lt;/P&gt;&lt;P&gt;chilli 500g&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=a;&lt;/P&gt;&lt;P&gt;by name;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My required output is:&lt;/P&gt;&lt;P&gt;chilli 10g&lt;/P&gt;&lt;P&gt;chilli 15g&lt;/P&gt;&lt;P&gt;chilli 100g&lt;/P&gt;&lt;P&gt;chilli 150g&lt;/P&gt;&lt;P&gt;chilli 200g&lt;/P&gt;&lt;P&gt;chilli 250g&lt;/P&gt;&lt;P&gt;chilli 500g&lt;/P&gt;&lt;P&gt;chilli 1kg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 09:02:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176804#M33850</guid>
      <dc:creator>avinesh</dc:creator>
      <dc:date>2014-05-29T09:02:09Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176805#M33851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to split the numeric part out from the text, multiply it per the unit, then sort by that value:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table WANT (drop=WEIGHT) as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select&amp;nbsp; NAME,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case&amp;nbsp; when index(NAME,"kg")&amp;gt;0 then input(tranwrd(tranwrd(NAME,"chilli",""),"kg",""),best.) * 1000&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; else input(tranwrd(tranwrd(NAME,"chilli",""),"g",""),best.) end as WEIGHT&lt;/P&gt;&lt;P&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;&amp;nbsp; order by WEIGHT;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 09:15:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176805#M33851</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-05-29T09:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176806#M33852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI RW9&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the sample data i mentioned only chilli But in real time data im having many products with different names for example&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data a;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;infile datalines dlm=',';&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;input name $ 15.;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;cards;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;chilli 10g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;chilli 100g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;chilli 15g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;chilli 200g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;chilli 150g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;chilli 1kg&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;chilli 250g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;chilli 500g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Tumeric 10g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Tumeric 100g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Tumeric 15g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Masala 200g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Masala 150g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Masala 1kg&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Papad 250g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Papad 500g&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;run;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;If i get a solution for this,it will be more helpful for me can you help me out thanks in advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 09:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176806#M33852</guid>
      <dc:creator>avinesh</dc:creator>
      <dc:date>2014-05-29T09:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Sorting issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176807#M33853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming its just one word at the beginning you could change to:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp; create table WANT (drop=WEIGHT) as&lt;/P&gt;&lt;P&gt;&amp;nbsp; select&amp;nbsp; NAME,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; case&amp;nbsp; when index(NAME,"kg")&amp;gt;0 then input(tranwrd(substr(NAME,1,index(NAME," ")),"kg",""),best.) * 1000&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; else input(tranwrd(substr(NAME,1,index(NAME," ")),"g",""),best.) end as WEIGHT&lt;/P&gt;&lt;P&gt;&amp;nbsp; from&amp;nbsp;&amp;nbsp;&amp;nbsp; A&lt;/P&gt;&lt;P&gt;&amp;nbsp; order by WEIGHT;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You just need to modify the input part to manipulate the string to get only the number part, that depends on you data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 09:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sorting-issue/m-p/176807#M33853</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-05-29T09:33:10Z</dc:date>
    </item>
  </channel>
</rss>

