<?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: Assign order variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805890#M317472</link>
    <description>&lt;P&gt;It is a good way to reorder.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We pay more attention to the count number to see it belongs to which category. For those missing category, no study meaning for us, so keep it in the last.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 04 Apr 2022 16:50:23 GMT</pubDate>
    <dc:creator>JillChen0131</dc:creator>
    <dc:date>2022-04-04T16:50:23Z</dc:date>
    <item>
      <title>Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805887#M317470</link>
      <description>&lt;P&gt;I have a dataset like as below, I need to assign the order based on descending count order to this dataset, when the category is missing, it should be the last in order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Category&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Count&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; aa&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; bb&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; cc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; dd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Desired output:&lt;/P&gt;&lt;P&gt;Category&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Count&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Order&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; aa&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; bb&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; cc&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 8&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; dd&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 16:41:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805887#M317470</guid>
      <dc:creator>JillChen0131</dc:creator>
      <dc:date>2022-04-04T16:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805888#M317471</link>
      <description>&lt;P&gt;Replace the missing value of CATEGORY with a text string not likely to appear in real data, such as "ZZZZZZ". Sort the data by CATEGORY. Assign the value of ORDER. Then replace&amp;nbsp;"ZZZZZZ" with missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which brings up the question, why would you need a specific sort order variable after change missing to "ZZZZZZ"? Why not just use CATEGORY at this point?&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 16:47:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805888#M317471</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-04T16:47:49Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805890#M317472</link>
      <description>&lt;P&gt;It is a good way to reorder.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We pay more attention to the count number to see it belongs to which category. For those missing category, no study meaning for us, so keep it in the last.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 16:50:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805890#M317472</guid>
      <dc:creator>JillChen0131</dc:creator>
      <dc:date>2022-04-04T16:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805891#M317473</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411887"&gt;@JillChen0131&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;It is a good way to reorder.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We pay more attention to the count number to see it belongs to which category. For those missing category, no study meaning for us, so keep it in the last.&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I find this confusing. Using a category number is fine if you want to know which category is 3rd, but you didn't say that. And since the sorting is alphabetical, I'm not sure I see value in knowing that a particular category is 3rd alphabetically.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 16:53:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805891#M317473</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-04-04T16:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805892#M317474</link>
      <description>&lt;P&gt;I found assigning the missing category to "zzzzzz" is not working. I would need to sort the dataset by descending count first, based on that, all other categories need to go above the missing one, even the count is less than the missing one.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 17:04:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805892#M317474</guid>
      <dc:creator>JillChen0131</dc:creator>
      <dc:date>2022-04-04T17:04:22Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805893#M317475</link>
      <description>&lt;P&gt;the category may not &lt;SPAN&gt;alphabetically.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 17:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805893#M317475</guid>
      <dc:creator>JillChen0131</dc:creator>
      <dc:date>2022-04-04T17:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805898#M317477</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411887"&gt;@JillChen0131&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can create the order with a PROC SQL view and then assign the observation number to variable &lt;FONT face="courier new,courier"&gt;Order&lt;/FONT&gt; in a DATA step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Category $ Count;
cards;
aa 10
bb 9
cc 8
.  6
dd 3
;

proc sql;
create view _tmp as
select * from have
order by missing(category), count desc, category;
quit;

data want;
set _tmp;
Order=_n_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Apr 2022 17:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805898#M317477</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-04-04T17:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805902#M317478</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/411887"&gt;@JillChen0131&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;the category may not &lt;SPAN&gt;alphabetically.&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So how do we know what "order" to apply to anything? Do you have another data set somewhere with a specified order??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hint: your example data must be representative of the actual data is use. If you imply an order of values, such as your values of aa, bb, cc then we have to assume that the values are in order. Especially since the request involves ordering something and the only thing in your "want" is that except for the missing value they are in order.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 17:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805902#M317478</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-04T17:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805904#M317480</link>
      <description>Order is based on the count. The missing category goes to the last whatever the count is, any other category above it should be ordered by descending count.</description>
      <pubDate>Mon, 04 Apr 2022 17:45:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805904#M317480</guid>
      <dc:creator>JillChen0131</dc:creator>
      <dc:date>2022-04-04T17:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Assign order variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805905#M317481</link>
      <description>&lt;P&gt;This works for me. Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 17:50:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-order-variable/m-p/805905#M317481</guid>
      <dc:creator>JillChen0131</dc:creator>
      <dc:date>2022-04-04T17:50:26Z</dc:date>
    </item>
  </channel>
</rss>

