<?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: Order rows by user defined criteria in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793135#M254164</link>
    <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I want to order the rows in the way that for each customer there will be the following order or rows&lt;/P&gt;
&lt;P&gt;Wealth&lt;BR /&gt;Cycle&lt;BR /&gt;Educ&lt;BR /&gt;Age&lt;BR /&gt;Inter&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Create a new variable which is one when the value is "Wealth" and 2 when the value is "Cycle" and so on, then sort by this new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 28 Jan 2022 14:23:09 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-01-28T14:23:09Z</dc:date>
    <item>
      <title>Order rows by user defined criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793132#M254161</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;In real life I have a data set in Long structure where each customer has multiple rows.&lt;/P&gt;
&lt;P&gt;In each row there is information on&amp;nbsp;explanatory variables from regression model.&lt;/P&gt;
&lt;P&gt;I want to order the rows in the way that for each customer there will be the following order or rows&lt;/P&gt;
&lt;P&gt;Wealth&lt;BR /&gt;Cycle&lt;BR /&gt;Educ&lt;BR /&gt;Age&lt;BR /&gt;Inter&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;P&gt;The order is not by alphabetical order&amp;nbsp; (it is by user defined criteria)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data have;
input category $;
cards;
Inter
Age
Educ
Wealth
Cycle
;
Run;


Data wanted;
input category $;
cards;
Wealth
Cycle
Educ
Age
Inter
;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jan 2022 14:17:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793132#M254161</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-01-28T14:17:16Z</dc:date>
    </item>
    <item>
      <title>Re: Order rows by user defined criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793135#M254164</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;I want to order the rows in the way that for each customer there will be the following order or rows&lt;/P&gt;
&lt;P&gt;Wealth&lt;BR /&gt;Cycle&lt;BR /&gt;Educ&lt;BR /&gt;Age&lt;BR /&gt;Inter&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;Create a new variable which is one when the value is "Wealth" and 2 when the value is "Cycle" and so on, then sort by this new variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Jan 2022 14:23:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793135#M254164</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-01-28T14:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Order rows by user defined criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793137#M254165</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table want as
   select category from have
   order by whichc(category, 'Wealth', 
                             'Cycle',
                             'Educ',
                             'Age',
                             'Inter');
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Jan 2022 14:23:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793137#M254165</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-01-28T14:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: Order rows by user defined criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793349#M254267</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;if this works for you, please mark it as the solution.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Jan 2022 11:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793349#M254267</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2022-01-30T11:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Order rows by user defined criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793376#M254285</link>
      <description>It is a good solution  but in real world I need to sort by customer  ID and then by user defined category order and here it is not working  well</description>
      <pubDate>Sun, 30 Jan 2022 15:54:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793376#M254285</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-01-30T15:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Order rows by user defined criteria</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793377#M254286</link>
      <description>This is the best solution  and works well always . Thank you</description>
      <pubDate>Sun, 30 Jan 2022 15:55:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Order-rows-by-user-defined-criteria/m-p/793377#M254286</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2022-01-30T15:55:17Z</dc:date>
    </item>
  </channel>
</rss>

