<?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 - Sort Variable Which Includes Both Numeric and Character Value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241780#M44825</link>
    <description>&lt;P&gt;I like SQL way better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Length ReferenceID $ 10;
Infile Datalines Missover;
Input ReferenceID;
Datalines;
Tur1
Tur2
Tur10
Tur11
Tur5
Tur6
Tur9
Tur14
Tur15
Tur7
Tur8
Tur12
Tur13
Tur3
Tur4
;
Run;
proc sql;
 create table want as 
  select *
   from have
    order by input(compress(ReferenceID,,'kd'),best.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Jan 2016 05:20:21 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-01-05T05:20:21Z</dc:date>
    <item>
      <title>How to - Sort Variable Which Includes Both Numeric and Character Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241770#M44822</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to sort the variable ReferenceID. This variable includes both character and numeric datas. Type of ReferenceID is character. When I sort this variable , double-digit values come before one-digit values. I would like to sort this variable according to numeric values. I shared a basic data as below and desired output. I'm not sure is it possible. Does anybody has knowledge about this case ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Length ReferenceID $ 10;
Infile Datalines Missover;
Input ReferenceID;
Datalines;
Tur1
Tur2
Tur10
Tur11
Tur5
Tur6
Tur9
Tur14
Tur15
Tur7
Tur8
Tur12
Tur13
Tur3
Tur4
;
Run;

Proc Sort Data=Have;
By ReferenceID;
Run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/1362iD214E2D561383377/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Desired.png" title="Desired.png" /&gt;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 00:18:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241770#M44822</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2016-01-05T00:18:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Sort Variable Which Includes Both Numeric and Character Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241775#M44823</link>
      <description>&lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Question-about-the-order-of-memname-and-indsname/m-p/238655#M34633" target="_blank"&gt;https://communities.sas.com/t5/General-SAS-Programming/Question-about-the-order-of-memname-and-indsname/m-p/238655#M34633&lt;/A&gt;</description>
      <pubDate>Tue, 05 Jan 2016 00:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241775#M44823</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-01-05T00:43:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Sort Variable Which Includes Both Numeric and Character Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241776#M44824</link>
      <description>&lt;P&gt;Please try with sortseq option in proc sort&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc Sort Data=Have sortseq=linguistic(NUMERIC_COLLATION=on);
By ReferenceID;
Run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jan 2016 00:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241776#M44824</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2016-01-05T00:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Sort Variable Which Includes Both Numeric and Character Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241780#M44825</link>
      <description>&lt;P&gt;I like SQL way better.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data Have;
Length ReferenceID $ 10;
Infile Datalines Missover;
Input ReferenceID;
Datalines;
Tur1
Tur2
Tur10
Tur11
Tur5
Tur6
Tur9
Tur14
Tur15
Tur7
Tur8
Tur12
Tur13
Tur3
Tur4
;
Run;
proc sql;
 create table want as 
  select *
   from have
    order by input(compress(ReferenceID,,'kd'),best.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jan 2016 05:20:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241780#M44825</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-01-05T05:20:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to - Sort Variable Which Includes Both Numeric and Character Value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241807#M44832</link>
      <description>&lt;P&gt;You may want to consider another reference id in this case, the Tur doesn't actually add anything to the data, the id is just the numeric part. &amp;nbsp;If you absolutely have to have a character field then padd to a fixed length. &amp;nbsp;It just makes your programming easier, for instance CDISC standards a subject identifier would take the form of:&lt;/P&gt;
&lt;P&gt;&amp;lt;study&amp;gt;_&amp;lt;site&amp;gt;&amp;lt;subject&amp;gt;&lt;/P&gt;
&lt;P&gt;Fixed width for each, and it makes it simple to extract each part (although each part is available separately anyways for ease of processing), and sort etc.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2016 09:48:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-Sort-Variable-Which-Includes-Both-Numeric-and-Character/m-p/241807#M44832</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-01-05T09:48:10Z</dc:date>
    </item>
  </channel>
</rss>

