<?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: Column Orders and Retain (how to amend order of variables towards the end of datasets) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361539#M85285</link>
    <description>&lt;P&gt;Thanks for the reply!!&amp;nbsp; I've never seen that before but it worked fine for my dataset.&amp;nbsp; It's amazing how&amp;nbsp;much there is to learn&amp;nbsp;in SAS even if you 'think' you are fairly proficient &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for your time and what a very helpful community &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 May 2017 11:59:31 GMT</pubDate>
    <dc:creator>Brickinnit</dc:creator>
    <dc:date>2017-05-25T11:59:31Z</dc:date>
    <item>
      <title>Column Orders and Retain (how to amend order of variables towards the end of datasets)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361527#M85282</link>
      <description>&lt;P&gt;Hey Follow SAS Users!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a quick question which I hope you can help with.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I have a dataset with many columns and I just want to re-order a couple of them towards the end of the dataset, is there something simple I can use?&amp;nbsp; Using retain and re-ordering the 25th and 26th variables (y and z in this case), I would have to do the following code for example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;data work.order;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp; retain a b c d e f g h i j k l m n o p q r s t u v w x &lt;FONT size="5"&gt;&lt;STRONG&gt;z y;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&amp;nbsp;&lt;FONT size="3"&gt;&amp;nbsp;&lt;FONT size="2"&gt;set x.order;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;run;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;So, I would have to enter the preceding 24 variables before I can amend the order of the last two at the end.&amp;nbsp; Anything I'm missing/can be done to avoid entering the preceding 24 variables?&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;Hope that's clear &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;I did search and found lots on retain but couldn't find anything that specifically helps with the above.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2"&gt;&lt;FONT size="3"&gt;&lt;FONT size="2"&gt;Thanks in advance all.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 10:56:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361527#M85282</guid>
      <dc:creator>Brickinnit</dc:creator>
      <dc:date>2017-05-25T10:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Column Orders and Retain (how to amend order of variables towards the end of datasets)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361532#M85284</link>
      <description>&lt;P&gt;Here's a way to get around that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;if 5=4 then set have (drop=y z);&lt;/P&gt;
&lt;P&gt;retain z y;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first SET statement doesn't actually read any data (unless you invent some new type of math where 5=4). &amp;nbsp;But it orders all variables except Y and Z.&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 11:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361532#M85284</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-25T11:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: Column Orders and Retain (how to amend order of variables towards the end of datasets)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361539#M85285</link>
      <description>&lt;P&gt;Thanks for the reply!!&amp;nbsp; I've never seen that before but it worked fine for my dataset.&amp;nbsp; It's amazing how&amp;nbsp;much there is to learn&amp;nbsp;in SAS even if you 'think' you are fairly proficient &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks again for your time and what a very helpful community &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 11:59:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361539#M85285</guid>
      <dc:creator>Brickinnit</dc:creator>
      <dc:date>2017-05-25T11:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Column Orders and Retain (how to amend order of variables towards the end of datasets)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361576#M85305</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Here's a way to get around that:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;if 5=4 then set have (drop=y z);&lt;/P&gt;
&lt;P&gt;retain z y;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first SET statement doesn't actually read any data (unless you invent some new type of math where 5=4). &amp;nbsp;But it orders all variables except Y and Z.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry 'Astounding' one quick question - what does the 'if 5=4 then' actually do?&amp;nbsp; If you take that away, it still works - i.e., code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have (drop=y z);&lt;/P&gt;
&lt;P&gt;retain z y;&lt;/P&gt;
&lt;P&gt;set have;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 13:06:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361576#M85305</guid>
      <dc:creator>Brickinnit</dc:creator>
      <dc:date>2017-05-25T13:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Column Orders and Retain (how to amend order of variables towards the end of datasets)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361579#M85307</link>
      <description>&lt;P&gt;Since 5=4 is false, the first SET statement never executes.&amp;nbsp; While you can remove it, the DATA step takes longer to run that way because the first SET statement now actually reads in data.&amp;nbsp; I'm not sure if this is clever or not, but you could split up the work between the two SET statements:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set have (drop=y z);&lt;/P&gt;
&lt;P&gt;retain z y;&lt;/P&gt;
&lt;P&gt;set have (keep=y z);&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 13:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361579#M85307</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-25T13:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Column Orders and Retain (how to amend order of variables towards the end of datasets)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361583#M85309</link>
      <description>&lt;P&gt;Ah ha - OK!&amp;nbsp; Thanks for the info once again&lt;/P&gt;</description>
      <pubDate>Thu, 25 May 2017 13:21:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Column-Orders-and-Retain-how-to-amend-order-of-variables-towards/m-p/361583#M85309</guid>
      <dc:creator>Brickinnit</dc:creator>
      <dc:date>2017-05-25T13:21:19Z</dc:date>
    </item>
  </channel>
</rss>

