<?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: rearrae variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67331#M14576</link>
    <description>Humbly, you still have not explained why it is important to know or even care how SAS stores the information internally, even if you had the capability or control.  However, as mentioned, the RETAIN statement, though I don't recommend it, will give you to establish a "default order" (not to be confused with any SAS-managed internal sequence) for the variables/columns in your SAS dataset/table.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
    <pubDate>Wed, 26 Aug 2009 21:11:42 GMT</pubDate>
    <dc:creator>sbb</dc:creator>
    <dc:date>2009-08-26T21:11:42Z</dc:date>
    <item>
      <title>rearrae variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67326#M14571</link>
      <description>I have a quick question about changing the internal order of&lt;BR /&gt;
variables in a datset.&lt;BR /&gt;
I have a dataset with 23 variables. But I need them to be arrang in a specific order.&lt;BR /&gt;
&lt;BR /&gt;
for instance &lt;BR /&gt;
provider PATIENT_ID ndc_number NDC_DESC lot_No &lt;BR /&gt;
&lt;BR /&gt;
are to be arranged as:&lt;BR /&gt;
ndc_number NDC_DESC PATIENT_ID  lot_No provider</description>
      <pubDate>Wed, 26 Aug 2009 19:55:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67326#M14571</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-08-26T19:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: rearrae variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67327#M14572</link>
      <description>Why do you feel they need to be re-arranged, internally?  You have no control now SAS stores the variables, other than when generated by-default order with say PROC PRINT and no VAR statement listed.  You can influence the declared order of your SAS variables by defining a RETAIN statement (ahead of the SET, if coded) in the desired order - be careful using the RETAIN statement as has been discussed on the various SAS topic forums on the planet.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 26 Aug 2009 20:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67327#M14572</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-08-26T20:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: rearrange variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67328#M14573</link>
      <description>Scott is 100% right with regard to sound practice.  With so many SAS reporting procedures that let you order columns as needed, there is really no reason to need this.  However, an audience raised in Excel is an audience that is accustomed to moving columns around.   Thus,  I can see where this issue originates. &lt;BR /&gt;
&lt;BR /&gt;
Base SAS VIEWTABLE, and SAS Enterprise Guide  give a default view of the data.   In some cases, I can see why people might want the most interesting variables "at the left".   I've been known to force an ATTRIB statement before the SET statement so that "my favorites" come up on the left in a new view.  &lt;BR /&gt;
&lt;BR /&gt;
But for the most part I agree with Scott.  &lt;BR /&gt;
&lt;BR /&gt;
data test / view=test;&lt;BR /&gt;
   attrib age label='Age' weight label='Weight' sex label='Sex' height label='Height' name label='Name';&lt;BR /&gt;
   set sashelp.class;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
If you now click on WORK.TEST in the explorer, the data will appear in the order listed on the ATTRIB statement.  But really, other ways are better.</description>
      <pubDate>Wed, 26 Aug 2009 20:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67328#M14573</guid>
      <dc:creator>mftuchman</dc:creator>
      <dc:date>2009-08-26T20:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: rearrae variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67329#M14574</link>
      <description>These variable names seem *awfully* familiar.  You work in my office? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 26 Aug 2009 20:33:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67329#M14574</guid>
      <dc:creator>mftuchman</dc:creator>
      <dc:date>2009-08-26T20:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: rearrae variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67330#M14575</link>
      <description>Thanks Scott!&lt;BR /&gt;
I created a dataset using the  describe statement and arranged the variables of the order i want and appened the original dataset to it.</description>
      <pubDate>Wed, 26 Aug 2009 20:52:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67330#M14575</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2009-08-26T20:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: rearrae variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67331#M14576</link>
      <description>Humbly, you still have not explained why it is important to know or even care how SAS stores the information internally, even if you had the capability or control.  However, as mentioned, the RETAIN statement, though I don't recommend it, will give you to establish a "default order" (not to be confused with any SAS-managed internal sequence) for the variables/columns in your SAS dataset/table.&lt;BR /&gt;
&lt;BR /&gt;
Scott Barry&lt;BR /&gt;
SBBWorks, Inc.</description>
      <pubDate>Wed, 26 Aug 2009 21:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67331#M14576</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-08-26T21:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: rearrae variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67332#M14577</link>
      <description>&amp;gt; Humbly, you still have not explained why it is&lt;BR /&gt;
&amp;gt; important to know or even care how SAS stores the&lt;BR /&gt;
&amp;gt; information internally, even if you had the&lt;BR /&gt;
&amp;gt; capability or control.  However, as mentioned, the&lt;BR /&gt;
&amp;gt; RETAIN statement, though I don't recommend it, will&lt;BR /&gt;
&amp;gt; give you to establish a "default order" (not to be&lt;BR /&gt;
&amp;gt; confused with any SAS-managed internal sequence) for&lt;BR /&gt;
&amp;gt; the variables/columns in your SAS dataset/table.&lt;BR /&gt;
&lt;BR /&gt;
I think the OP means VARNUM order.  We know that SAS doesn't necessary store the columns in VARNUM order but that is unimportant for this discussion.&lt;BR /&gt;
&lt;BR /&gt;
VARNUM order is not important most of the time but there are times when clients want variables in a certain order.  When that is the case I usually create the variable in the proper order.  However there are times when it is necessary to move the columns around, and for that the RETAIN statement is the most concise method.  I know that some SAS users have "retain-a-phobia".  Perhaps the following example will help.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
proc contents data=sashelp.shoes order=varnum;&lt;BR /&gt;
   run;&lt;BR /&gt;
data newShoes;&lt;BR /&gt;
   stop;&lt;BR /&gt;
   retain&lt;BR /&gt;
      Inventory&lt;BR /&gt;
      Region&lt;BR /&gt;
      Product&lt;BR /&gt;
      Subsidiary&lt;BR /&gt;
      Stores&lt;BR /&gt;
      Sales&lt;BR /&gt;
      Returns&lt;BR /&gt;
      ;&lt;BR /&gt;
   set sashelp.shoes;&lt;BR /&gt;
   run;&lt;BR /&gt;
data newShoes;&lt;BR /&gt;
   set newShoes sashelp.shoes;&lt;BR /&gt;
   *** Perhaps more code;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc contents data=newShoes order=varnum;&lt;BR /&gt;
   run; &lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 27 Aug 2009 15:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67332#M14577</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-08-27T15:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: rearrae variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67333#M14578</link>
      <description>Wait - that really didn't feel so bad!  &lt;BR /&gt;
&lt;BR /&gt;
Thanks data _null_;&lt;BR /&gt;
&lt;BR /&gt;
Scott</description>
      <pubDate>Thu, 27 Aug 2009 16:28:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/rearrae-variables/m-p/67333#M14578</guid>
      <dc:creator>sbb</dc:creator>
      <dc:date>2009-08-27T16:28:50Z</dc:date>
    </item>
  </channel>
</rss>

