<?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 of alpha_numeric like contents of book in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310373#M66933</link>
    <description>If you can manipulate data then how it can be done?&lt;BR /&gt;Can you please write code?</description>
    <pubDate>Wed, 09 Nov 2016 13:56:55 GMT</pubDate>
    <dc:creator>abhaykumar</dc:creator>
    <dc:date>2016-11-09T13:56:55Z</dc:date>
    <item>
      <title>sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310366#M66930</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I want to sort this as it is in book contents page, data is as follows :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data assignment2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;infile cards;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;input var $ 30.;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;cards;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_1_Contents&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_2_Introduction&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_3_History1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_4_History2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_5_History3&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_6_History4&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_7_History5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_8_History6&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_8_History7&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_10_History8&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_11_History9&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_12_History10&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_13_Appendix&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_1A_Foreword&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_1B_Preface&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_1C_Acknowledgments&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_13A_AppendixA&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_13B_AppendixB&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_13C_AppendixC&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_2A_Prologue&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_14_Notes&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_15_Glossary&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_16_References&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Table_17_Index&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Expected output should be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_1_Contents&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_1A_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_1B_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_1C_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_2_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_2A_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_2B_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_2C_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_3_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Table_2A_&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;......... like that ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I hope you understand what I want.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks you.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 13:31:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310366#M66930</guid>
      <dc:creator>abhaykumar</dc:creator>
      <dc:date>2016-11-09T13:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310369#M66931</link>
      <description>&lt;P&gt;SAS sort char variables&amp;nbsp;by position in the string, and I don't see that this&amp;nbsp;can be done without manipulating the data.&lt;/P&gt;
&lt;P&gt;I would insert a char between the chapter no and the specific section chars (A, B and C). it needs to be a char with an ASCII&amp;nbsp;value lower than A and the numbers, so space seems like a natural choice.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 13:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310369#M66931</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-11-09T13:50:13Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310373#M66933</link>
      <description>If you can manipulate data then how it can be done?&lt;BR /&gt;Can you please write code?</description>
      <pubDate>Wed, 09 Nov 2016 13:56:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310373#M66933</guid>
      <dc:creator>abhaykumar</dc:creator>
      <dc:date>2016-11-09T13:56:55Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310374#M66934</link>
      <description>Hi,&lt;BR /&gt;To solve this the only thing that come to my mind is to create a new variable with the second word deleting all categorical information (could be done with a compress(xxxx,'0123456789','K')) and the same with other variable keeping only the caregorical info (compress deleting the 'K' option), then you could do a sort by this two new vars.</description>
      <pubDate>Wed, 09 Nov 2016 13:56:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310374#M66934</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2016-11-09T13:56:58Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310376#M66935</link>
      <description>&lt;P&gt;You need extra columns for the sort:&lt;/P&gt;
&lt;PRE&gt;data assignment2;
  infile cards;
  input var $ 30.;
cards;
Table_1_Contents
Table_2_Introduction
Table_3_History1
Table_4_History2
Table_5_History3
Table_6_History4
Table_7_History5
Table_8_History6
Table_8_History7
Table_10_History8
Table_11_History9
Table_12_History10
Table_13_Appendix
Table_1A_Foreword
Table_1B_Preface
Table_1C_Acknowledgments
Table_13A_AppendixA
Table_13B_AppendixB
Table_13C_AppendixC
Table_2A_Prologue
Table_14_Notes
Table_15_Glossary
Table_16_References
Table_17_Index
;
run;
data want;
  set assignment2;
  main=input(compress(scan(var,2,"_"),,"KD"),best.);
  sec=compress(scan(var,2,"_"),,"KA");
run;
proc sort data=want;
  by main sec;
run;&lt;/PRE&gt;
&lt;P&gt;However you can also do (same test data):&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  *
  from    ASSIGNMENT2
  order by input(compress(scan(var,2,"_"),,"KD"),best.),
            compress(scan(var,2,"_"),,"KA");
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Nov 2016 14:03:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310376#M66935</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-09T14:03:34Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310381#M66939</link>
      <description>&lt;P&gt;Since no ones mentioned it, it may not apply in this situation but you can sometimes use the SORTSEQ option in PROC SORT to sort character variables that have numbers in it correctly.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#p02bhn81rn4u64n1b6l00ftdnxge.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/proc/68954/HTML/default/viewer.htm#p02bhn81rn4u64n1b6l00ftdnxge.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 14:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310381#M66939</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-09T14:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310430#M66947</link>
      <description>&lt;P&gt;I am going to assume that you are using a version of SAS 9.2 or later. I am not going to write code as this looks like a school assignment and you need to learn but some&amp;nbsp;hints:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Sort has an option SORTSEQ that allows you to specify some rules to sort with. One of the rules is Linguistic which supports an option NUMERIC_COLLATION.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 16:01:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310430#M66947</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-11-09T16:01:20Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310435#M66948</link>
      <description>Thank You sir, I got the explanation.&lt;BR /&gt;But I am still confused about the third argument of compress function "KD" and "KA". Can you please elaborate on that because my i have not read anything about three argument in the compress function.</description>
      <pubDate>Wed, 09 Nov 2016 16:12:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310435#M66948</guid>
      <dc:creator>abhaykumar</dc:creator>
      <dc:date>2016-11-09T16:12:33Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310438#M66949</link>
      <description>Thank you sir for you help.&lt;BR /&gt;and NO sir this is NOT any college or school assignment, I am self learning SAS, try to solve any problem I get from anywhere.</description>
      <pubDate>Wed, 09 Nov 2016 16:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310438#M66949</guid>
      <dc:creator>abhaykumar</dc:creator>
      <dc:date>2016-11-09T16:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: sorting of alpha_numeric like contents of book</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310440#M66951</link>
      <description>&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000212246.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Basically the third parameter is for options. &amp;nbsp;So you could put A in ther to add all alphabetic characters to the list of complress characters. &amp;nbsp;In my case I use K to reverse the logic of the function, instead of dropping those in the list I keep them, so you could look at like compress the text Keeping Digits.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2016 16:22:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sorting-of-alpha-numeric-like-contents-of-book/m-p/310440#M66951</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-11-09T16:22:46Z</dc:date>
    </item>
  </channel>
</rss>

