<?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: keep variable at the back in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101451#M28483</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And if you don't want to spell out your variable names if there are many, try to use metadata:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select name into :name separated by ' ' from dictionary.columns&amp;nbsp; &lt;/P&gt;&lt;P&gt;where libname='WORK' AND MEMNAME='TEST2' AND NAME NE 'STORE'; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;retain &amp;amp;name STORE;&lt;/P&gt;&lt;P&gt;set TEST2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 May 2012 18:39:00 GMT</pubDate>
    <dc:creator>Haikuo</dc:creator>
    <dc:date>2012-05-02T18:39:00Z</dc:date>
    <item>
      <title>keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101444#M28476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, does anyone know how I can keep a variable to the back if using merge, set or proc means or proc transpose...I knwo retain keeps it in formation, but how can I always keep a new variable added to the back..&amp;nbsp; thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 17:38:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101444#M28476</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2012-05-02T17:38:05Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101445#M28477</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your question is too general to be answered. It seems to me that you want a variable to be retained,&amp;nbsp; if that is the case, in data step you can use &lt;/P&gt;&lt;P&gt;1. retain statement&lt;/P&gt;&lt;P&gt;2. sum statement&lt;/P&gt;&lt;P&gt;3. DOW.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You maybe need to lay out some detailed scenario for specific answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 17:46:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101445#M28477</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-05-02T17:46:22Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101446#M28478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you mean add it to the end of a data set, so that if your current data set has two variables&lt;/P&gt;&lt;P&gt;ID Var1&lt;/P&gt;&lt;P&gt;and you add a new variable Var2 your data should be&lt;/P&gt;&lt;P&gt;ID Var1 Var2?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 17:49:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101446#M28478</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-05-02T17:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101447#M28479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I mean if I have this code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;transpose&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=Test &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=Test2 (drop=_name_ _label_) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;suffix&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;=_Price; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; City Store;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; Price;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: blue; font-family: 'Courier New';"&gt;id&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt; Date;&lt;/SPAN&gt;&lt;STRONG style="color: navy; background: white; font-size: 10pt; font-family: 'Courier New';"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; background: white; color: black; font-family: 'Courier New';"&gt;It stores the Store right in the front, but how can I put the Store right at the back behind all the Prices..?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 17:56:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101447#M28479</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2012-05-02T17:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101448#M28480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If I understand you correctly, you would need anther additional step (eg. data step) to get what you need. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;retain blah1 blah2 .... col1 col2... &lt;STRONG&gt;STORE&lt;/STRONG&gt;;&lt;/P&gt;&lt;P&gt;set test2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 18:14:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101448#M28480</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-05-02T18:14:55Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101449#M28481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have tried that and it still leaves STORE at the front.. Let me put it another way..&lt;/P&gt;&lt;P&gt;If I have a dataset of STORE, Var1, Var2, Var3 -- Var20 .. How Can I make it to look like this&lt;/P&gt;&lt;P&gt;Var1, Var2, Var3 -- Var20, STORE .. thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 18:20:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101449#M28481</guid>
      <dc:creator>podarum</dc:creator>
      <dc:date>2012-05-02T18:20:44Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101450#M28482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It seems working for me, try this, make sure 'retain' statement runs before 'set'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;retain var1-var20 STORE;&lt;/P&gt;&lt;P&gt;set test2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 18:35:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101450#M28482</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-05-02T18:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101451#M28483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;And if you don't want to spell out your variable names if there are many, try to use metadata:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select name into :name separated by ' ' from dictionary.columns&amp;nbsp; &lt;/P&gt;&lt;P&gt;where libname='WORK' AND MEMNAME='TEST2' AND NAME NE 'STORE'; quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;retain &amp;amp;name STORE;&lt;/P&gt;&lt;P&gt;set TEST2;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 May 2012 18:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101451#M28483</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-05-02T18:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101452#M28484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is an easy way using DROP dataset option.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want ;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have(obs=0 drop=store) have;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use multiples of these zero obs datasets with combinations of keep and drop options to reorder variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2012 00:13:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101452#M28484</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-05-03T00:13:20Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101453#M28485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom, your mastery of the datastep keeps amazing me!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But at the same time, I feel somewhat annoyed that the simplest way to do certain things with SAS is to use side effects. Long time ago, when I learned to program, I was warned about relying on side effects to achieve my goals. They are often underdocumented and always poorly understood by newcomers. I wonder why the theme of variable ordering keeps coming back, as I am sure it has been for years, without SAS including some feature in the language to address it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Excuse the rant. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;PG&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2012 01:10:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101453#M28485</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2012-05-03T01:10:53Z</dc:date>
    </item>
    <item>
      <title>Re: keep variable at the back</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101454#M28486</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can always keep it as the last variable with defining it as the last statement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data class(drop=_age);&lt;/P&gt;&lt;P&gt; set sashelp.class(rename=(age=_age));&lt;/P&gt;&lt;P&gt; age=_age;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ksharp&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 May 2012 07:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/keep-variable-at-the-back/m-p/101454#M28486</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2012-05-03T07:54:57Z</dc:date>
    </item>
  </channel>
</rss>

