<?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: BY Group -- reorder within BY group based on condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384195#M91708</link>
    <description>Dear RW9 and gammotee , I tried both solutions, neither orders the wanted way (both move around internally the subgroups i.e. "KL3, "FD" ) . Thank you.</description>
    <pubDate>Mon, 31 Jul 2017 10:20:07 GMT</pubDate>
    <dc:creator>Zeus_Olympous</dc:creator>
    <dc:date>2017-07-31T10:20:07Z</dc:date>
    <item>
      <title>BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384186#M91703</link>
      <description>Dear all, I have the DATA SET HAVE with by groups as shown. I want dataset WANT where the by group is ordered as shown (I need them ordered by date as well). I cannot figure the right variable sort ordering. Any hint/suggestion would be more than welcome. Thank you. data HAVE; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; run; data WANT; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; run;</description>
      <pubDate>Mon, 31 Jul 2017 09:36:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384186#M91703</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T09:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384187#M91704</link>
      <description>&lt;P&gt;Why do you want this ordering of your data?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 09:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384187#M91704</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-07-31T09:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384189#M91705</link>
      <description>&lt;P&gt;When posting code use the {i} above the post area to preserve formatting and such like, otherwise it is just unreadable. &amp;nbsp;From what I gather you are having trouble sorting based on the text FD, KL etc. &amp;nbsp;As there appears to be no logical ordering, I would suggest you create a variable specifically for ordering and use that rather than the text field, maybe something like:&lt;/P&gt;
&lt;PRE&gt;data have;
  set have;
  select(t);
    when("KL") then ord=1;
    when("FD") then ord=2;
...
  end;
run;
proc sort data=have out=want;
  by group ord m;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 09:43:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384189#M91705</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-31T09:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384191#M91706</link>
      <description>&lt;P&gt;You can do it in a single step with proc sql :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
  CREATE TABLE want AS
  SELECT *
  FROM have
  ORDER BY CASE WHEN t="KL" THEN 1
                WHEN t="FD" THEN 2
                ...
           ELSE &amp;lt;n&amp;gt; END;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 09:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384191#M91706</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-07-31T09:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384194#M91707</link>
      <description>Dear RW9 and gammotee , I tried both solutions, neither orders the wanted way (both move around internally the subgroups i.e. "KL3, "FD" ) . Thank you.</description>
      <pubDate>Mon, 31 Jul 2017 10:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384194#M91707</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T10:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384195#M91708</link>
      <description>Dear RW9 and gammotee , I tried both solutions, neither orders the wanted way (both move around internally the subgroups i.e. "KL3, "FD" ) . Thank you.</description>
      <pubDate>Mon, 31 Jul 2017 10:20:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384195#M91708</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T10:20:07Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384198#M91710</link>
      <description>&lt;P&gt;So please clarify exactly what it is you want. &amp;nbsp;Your title - reorder within by group based on condition - indicates that you want the data in a different, non-logical order, thus I present an eample method to do this by creating a logical order variable to sort by.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 10:29:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384198#M91710</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-31T10:29:51Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384199#M91711</link>
      <description>I could not download the joint file because it is blocked by my employer's proxy and your initial post is unreadable for the reason pointed out by RW9. What should be the desired order ?</description>
      <pubDate>Mon, 31 Jul 2017 10:30:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384199#M91711</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-07-31T10:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384207#M91716</link>
      <description>For some reason I am not able to see the symbol that RW9 suggests. I will try to repost the HAVE and WANT, I hope that they will make sense. Thank you. data HAVE; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; run; data WANT; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; group=1; j=52; t='KL'; m='03Jan2015'; output; group=1; j=99; t='LL'; m='16Mar2016'; output; group=1; j=11; t='AA'; m='30Sep2016'; output; group=1; j=46; t='FD'; m='20Dec2016'; output; run;</description>
      <pubDate>Mon, 31 Jul 2017 10:51:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384207#M91716</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T10:51:59Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384209#M91717</link>
      <description>Unfortunately the problem persists.. Any way the contents of the first dataset (HAVE ) start from "data HAVE;" and end to the first "run;" The contents of the wanted dataset start from "data WANT;" and end to the second "run;"...I think it will work if copied and paste to SAS workspace. Thank you.</description>
      <pubDate>Mon, 31 Jul 2017 10:55:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384209#M91717</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T10:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384216#M91718</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/14229i191B13ED56070436/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Just below the word Preview in the attached image.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 10:59:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384216#M91718</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-31T10:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384221#M91722</link>
      <description>&lt;P&gt;Ok ..now it seems that works...please see attached HAVe and WANT.&amp;nbsp;&amp;nbsp; Actually I need a way to reorder the by group observations at will.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; HAVE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;WANT&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; WANT;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 11:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384221#M91722</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T11:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384229#M91723</link>
      <description>&lt;P&gt;Ok, so from what I see you posted there create a variable called ord, and set it to 1,2,3 or 4 depending on t variable, then sort by that:&lt;/P&gt;
&lt;PRE&gt;data have
  set have;
  select(t);
    when "KL" then ord=1;
    when "LL" then ord=2;
    when "AA" then ord=3;
    else ord=4;
  end;
run;
proc sort data=have;
  by group ord;
run; 
  &lt;/PRE&gt;
&lt;P&gt;And you can order at will, however as there is no logical sort approach here, you need to add that into the data.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 11:56:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384229#M91723</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-31T11:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384234#M91726</link>
      <description>&lt;P&gt;Dear RW9 ,&lt;/P&gt;&lt;P&gt;Unfortunately it does not do the trick.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As per your suggestion I used&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; HAVE;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;46&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'FD'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'20Dec2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;52&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'KL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'03Jan2015'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;99&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'LL'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'16Mar2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;group=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; j=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;11&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;; t=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'AA'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; m=&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'30Sep2016'&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;; &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;output&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;run&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; have;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;select&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;(t);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"KL"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) ord=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"LL"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) ord=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"AA"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) ord=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;3&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;when&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; (&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;"FD"&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;) ord=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;4&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;otherwise&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; ord=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;5&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/*** JUST a note otherwise should relace end ***/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;=want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; group ord;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and I get&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group&amp;nbsp;j&amp;nbsp;t&amp;nbsp;m&amp;nbsp;ord&lt;BR /&gt;1&amp;nbsp;52&amp;nbsp;KL&amp;nbsp;03Jan2015&amp;nbsp;1&lt;BR /&gt;1&amp;nbsp;52&amp;nbsp;KL&amp;nbsp;03Jan2015&amp;nbsp;1&lt;BR /&gt;1&amp;nbsp;52&amp;nbsp;KL&amp;nbsp;03Jan2015&amp;nbsp;1&lt;BR /&gt;1&amp;nbsp;52&amp;nbsp;KL&amp;nbsp;03Jan2015&amp;nbsp;1&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1&amp;nbsp;99&amp;nbsp;LL&amp;nbsp;16Mar2016&amp;nbsp;2&lt;BR /&gt;1&amp;nbsp;99&amp;nbsp;LL&amp;nbsp;16Mar2016&amp;nbsp;2&lt;BR /&gt;1&amp;nbsp;99&amp;nbsp;LL&amp;nbsp;16Mar2016&amp;nbsp;2&lt;BR /&gt;1&amp;nbsp;99&amp;nbsp;LL&amp;nbsp;16Mar2016&amp;nbsp;2&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1&amp;nbsp;11&amp;nbsp;AA&amp;nbsp;30Sep2016&amp;nbsp;3&lt;BR /&gt;1&amp;nbsp;11&amp;nbsp;AA&amp;nbsp;30Sep2016&amp;nbsp;3&lt;BR /&gt;1&amp;nbsp;11&amp;nbsp;AA&amp;nbsp;30Sep2016&amp;nbsp;3&lt;BR /&gt;1&amp;nbsp;11&amp;nbsp;AA&amp;nbsp;30Sep2016&amp;nbsp;3&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;1&amp;nbsp;46&amp;nbsp;FD&amp;nbsp;20Dec2016&amp;nbsp;4&lt;BR /&gt;1&amp;nbsp;46&amp;nbsp;FD&amp;nbsp;20Dec2016&amp;nbsp;4&lt;BR /&gt;1&amp;nbsp;46&amp;nbsp;FD&amp;nbsp;20Dec2016&amp;nbsp;4&lt;BR /&gt;1&amp;nbsp;46&amp;nbsp;FD&amp;nbsp;20Dec2016&amp;nbsp;4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;while I want&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;group&amp;nbsp;j&amp;nbsp;t&amp;nbsp;m&lt;BR /&gt;1&amp;nbsp;52&amp;nbsp;KL&amp;nbsp;03Jan2015&lt;BR /&gt;1&amp;nbsp;99&amp;nbsp;LL&amp;nbsp;16Mar2016&lt;BR /&gt;1&amp;nbsp;11&amp;nbsp;AA&amp;nbsp;30Sep2016&lt;BR /&gt;1&amp;nbsp;46&amp;nbsp;FD&amp;nbsp;20Dec2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;52&amp;nbsp;KL&amp;nbsp;03Jan2015&lt;BR /&gt;1&amp;nbsp;99&amp;nbsp;LL&amp;nbsp;16Mar2016&lt;BR /&gt;1&amp;nbsp;11&amp;nbsp;AA&amp;nbsp;30Sep2016&lt;BR /&gt;1&amp;nbsp;46&amp;nbsp;FD&amp;nbsp;20Dec2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;52&amp;nbsp;KL&amp;nbsp;03Jan2015&lt;BR /&gt;1&amp;nbsp;99&amp;nbsp;LL&amp;nbsp;16Mar2016&lt;BR /&gt;1&amp;nbsp;11&amp;nbsp;AA&amp;nbsp;30Sep2016&lt;BR /&gt;1&amp;nbsp;46&amp;nbsp;FD&amp;nbsp;20Dec2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1&amp;nbsp;52&amp;nbsp;KL&amp;nbsp;03Jan2015&lt;BR /&gt;1&amp;nbsp;99&amp;nbsp;LL&amp;nbsp;16Mar2016&lt;BR /&gt;1&amp;nbsp;11&amp;nbsp;AA&amp;nbsp;30Sep2016&lt;BR /&gt;1&amp;nbsp;46&amp;nbsp;FD&amp;nbsp;20Dec2016&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanking you in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:09:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384234#M91726</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T12:09:26Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384235#M91727</link>
      <description>&lt;P&gt;It seems that the same sample is repeated 4 times. Is it always the case ? If so, there is no need to&lt;/P&gt;
&lt;P&gt;store redundant information. Perform the custom sort on the dataset using either proposed method and&lt;/P&gt;
&lt;P&gt;eliminate duplicates.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384235#M91727</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-07-31T12:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384237#M91728</link>
      <description>&lt;P&gt;Another problem is you're storing a date as a text value which means when you sort it&amp;nbsp;20Dec2016 is coming before&amp;nbsp;30Sep2016. Also as mentioned holding duplicate key values is a very bad idea which will cause no end of problems further down the processing track....&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:26:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384237#M91728</guid>
      <dc:creator>ChrisBrooks</dc:creator>
      <dc:date>2017-07-31T12:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384241#M91730</link>
      <description>&lt;P&gt;Well, it doesn't make sense, but its still the same, you just need to identify order variables:&lt;/P&gt;
&lt;PRE&gt;data HAVE;
group=1; j=46; t='FD'; m='20Dec2016'; output;
group=1; j=46; t='FD'; m='20Dec2016'; output;
group=1; j=46; t='FD'; m='20Dec2016'; output;
group=1; j=46; t='FD'; m='20Dec2016'; output;
group=1; j=52; t='KL'; m='03Jan2015'; output;
group=1; j=52; t='KL'; m='03Jan2015'; output;
group=1; j=52; t='KL'; m='03Jan2015'; output;
group=1; j=52; t='KL'; m='03Jan2015'; output;
group=1; j=99; t='LL'; m='16Mar2016'; output;
group=1; j=99; t='LL'; m='16Mar2016'; output;
group=1; j=99; t='LL'; m='16Mar2016'; output;
group=1; j=99; t='LL'; m='16Mar2016'; output;
group=1; j=11; t='AA'; m='30Sep2016'; output;
group=1; j=11; t='AA'; m='30Sep2016'; output;
group=1; j=11; t='AA'; m='30Sep2016'; output;
group=1; j=11; t='AA'; m='30Sep2016'; output;
run;
 
proc sort data=have;
  by group t;
run;

data want;
  set have;
  retain ord2 1;
  by group t;
  ord2=ifn(first.t,1,ord2+1);
  select(t);
    when("KL") ord1=1;
    when("LL") ord1=2;
    when("AA") ord1=3;
    otherwise ord1=4;
  end;
run;

proc sort data=want;
  by group ord2 ord1;
run;&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384241#M91730</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-31T12:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384242#M91731</link>
      <description>&lt;P&gt;Dear Chris,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your responce.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are correct .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Allow me to clarify.&lt;/P&gt;&lt;P&gt;Although In the original dataset the date variable is stored in&lt;STRONG&gt; SAS date numeric values&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I convert it to&amp;nbsp;"character" to my example just to&amp;nbsp;highlight my request.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Still I am searching the net and I have found nothing&amp;nbsp; relevant.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:38:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384242#M91731</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T12:38:38Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384243#M91732</link>
      <description>&lt;P&gt;Dear RW9,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BRILLIANT!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It works like charm.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks a MILLION!&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384243#M91732</guid>
      <dc:creator>Zeus_Olympous</dc:creator>
      <dc:date>2017-07-31T12:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: BY Group -- reorder within BY group based on condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384248#M91736</link>
      <description>&lt;P&gt;Looking at your response to Chris, it may be worth looking at formats rather than creating a variable:&lt;/P&gt;
&lt;PRE&gt;proc format;
  value myfmt
    1="KL"
    2="LL"
...
run;
&lt;/PRE&gt;
&lt;P&gt;That way you keep your numeric data, can order correctly, and display text replacement when needed.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Jul 2017 12:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/BY-Group-reorder-within-BY-group-based-on-condition/m-p/384248#M91736</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-31T12:54:11Z</dc:date>
    </item>
  </channel>
</rss>

