<?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: ordering a variable in a custom way in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304878#M64949</link>
    <description>&lt;P&gt;Hi Shmuel,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt; format item table apple book;&lt;BR /&gt; set have;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But got the same result as before. Also, isn't the retain option for ordering variables? Becasue in my case I have one variable, its the rows within it that I want to re-order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Sat, 15 Oct 2016 18:13:17 GMT</pubDate>
    <dc:creator>ilikesas</dc:creator>
    <dc:date>2016-10-15T18:13:17Z</dc:date>
    <item>
      <title>ordering a variable in a custom way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304871#M64942</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose that I have the followng table with the variable item:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 48pt;" border="0" width="64" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD width="64" height="20" style="height: 15.0pt; width: 48pt;"&gt;item&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;book&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;table&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 15.0pt;"&gt;
&lt;TD height="20" style="height: 15.0pt;"&gt;apple&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I would like to order in the following way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="64"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;item&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;table&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;apple&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;book&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please note that the ordering is very custom-specific and I couldn't obtain it with sort by or order by options.&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;</description>
      <pubDate>Sat, 15 Oct 2016 16:34:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304871#M64942</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-10-15T16:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: ordering a variable in a custom way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304876#M64947</link>
      <description>&lt;P&gt;Thaere are several ways to force order of variables:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;/* &amp;nbsp;use RETAIN or LENGTH or FORMAT statement with order desired, for example: */&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format item table apple book;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; /* ... any cody if need */&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 17:49:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304876#M64947</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-15T17:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: ordering a variable in a custom way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304877#M64948</link>
      <description>&lt;P&gt;There are a couple of ways to go about this. &amp;nbsp;You could create a new variable, and sort by that one. &amp;nbsp;For example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;select (item);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when ('table') sortvar=1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when ('apple') sortvar=2;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when ('book') sortvar=3;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can sort by SORTVAR. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Technically, you asked how do this without sorting. &amp;nbsp;To do that, you still need to put the observations in order. &amp;nbsp;Here's one way (although you may need to embellish on it to get the result you are looking for):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data table apple book;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;select (item);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when ('table') output table;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when ('apple') output apple;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;when ('book') output book;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set table apple book;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Depending on the report you want in the end, some procedures support ORDER=DATA and will report the ITEMs in the same order as they appear in the data.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 18:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304877#M64948</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-10-15T18:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: ordering a variable in a custom way</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304878#M64949</link>
      <description>&lt;P&gt;Hi Shmuel,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt; format item table apple book;&lt;BR /&gt; set have;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But got the same result as before. Also, isn't the retain option for ordering variables? Becasue in my case I have one variable, its the rows within it that I want to re-order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Sat, 15 Oct 2016 18:13:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ordering-a-variable-in-a-custom-way/m-p/304878#M64949</guid>
      <dc:creator>ilikesas</dc:creator>
      <dc:date>2016-10-15T18:13:17Z</dc:date>
    </item>
  </channel>
</rss>

