<?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: Reorder variables with retain, some problem using prefix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574473#M162333</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269468"&gt;@Onizuka&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An alternative approach uses a "non-executable" SET statement in conjunction with selected KEEP= dataset options (where you &lt;EM&gt;can&lt;/EM&gt; use variable lists):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
retain d;
if 0 then set have(keep=b:) have(keep=a:);
set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; , thank you for your answer, I will try your solution too, thanks again ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2019 07:34:04 GMT</pubDate>
    <dc:creator>Onizuka</dc:creator>
    <dc:date>2019-07-18T07:34:04Z</dc:date>
    <item>
      <title>Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574097#M162145</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to reorder lot of variables but I can't reorder them using the ' : '&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
format a_1 a_2 a_3 b_1 b_2 d c $2. ;
input a_1 a_2 a_3 b_1 b_2 d c ;
cards;
a1 a2 a3 b1 b2 d c
a1 a2 a3 b1 b2 d c
;

Data want ;
retain d b: a: ;
set have ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a "trick" to do this on a retain without using a1-a3 b1-b2 ? Because on my real datas, there is no 1,2,3,4, ....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mateo&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 09:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574097#M162145</guid>
      <dc:creator>Onizuka</dc:creator>
      <dc:date>2019-07-17T09:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574106#M162152</link>
      <description>&lt;P&gt;The reason why this doesn't work is that when the data step hits the Retain Statement during compilation, it does not yet know what variables to look for with the colon operator because it has not yet reached the Set Statement.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you have to read the relevant variable names through metadata to achieve this. However, it may be more convenient just typing out the variable names. So if you are still interested, I will provide the code.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 09:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574106#M162152</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-17T09:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574107#M162153</link>
      <description>&lt;P&gt;Oh yes... true... Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31304"&gt;@PeterClemmensen&lt;/a&gt; .. !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a lot of variables, so yes, i can rename them "manually" but i would take a looong time !&lt;/P&gt;&lt;P&gt;I think that I have ~ 190 variables something like that ahaha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There are like :&lt;/P&gt;&lt;P&gt;a_q1_i1_nbrep&lt;/P&gt;&lt;P&gt;a_q1_i1_rests&lt;/P&gt;&lt;P&gt;a_q1_i1_value&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;a_q1_i2_nbrep&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;b_q1_.....&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if you have a piece of code, i would be very happy haha&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mateo&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 09:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574107#M162153</guid>
      <dc:creator>Onizuka</dc:creator>
      <dc:date>2019-07-17T09:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574108#M162154</link>
      <description>&lt;P&gt;Ok. There may be a smarter way, but this works.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have ;
format a_1 a_2 a_3 b_1 b_2 d c $2. ;
input a_1 a_2 a_3 b_1 b_2 d c ;
cards;
a1 a2 a3 b1 b2 d c
a1 a2 a3 b1 b2 d c
;

proc sql noprint;
    select name into :bvars separated by ' '
    from dictionary.columns
    where libname='WORK' &amp;amp; memname='HAVE' &amp;amp; name like 'b%';
    select name into :avars separated by ' '
    from dictionary.columns
    where libname='WORK' &amp;amp; memname='HAVE' &amp;amp; name like 'a%';
quit;

%put &amp;amp;bvars.;
%put &amp;amp;avars.;

Data want ;
retain d &amp;amp;bvars. &amp;amp;avars. ;
set have ;
run ;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jul 2019 09:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574108#M162154</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-17T09:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574110#M162156</link>
      <description>&lt;P&gt;Thanks to your idea, I was currently trying to do the same thing by going through the dictionary.columns &lt;SPAN&gt;but you have been much faster than me! haha&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I try this and I come back after &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In any case, thank you very much!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 09:48:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574110#M162156</guid>
      <dc:creator>Onizuka</dc:creator>
      <dc:date>2019-07-17T09:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574112#M162158</link>
      <description>&lt;P&gt;No problem, let me know if it works for you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 09:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574112#M162158</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2019-07-17T09:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574115#M162160</link>
      <description>&lt;P&gt;It seems to work ! Thank you for teaching me this &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Mateo&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2019 10:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574115#M162160</guid>
      <dc:creator>Onizuka</dc:creator>
      <dc:date>2019-07-17T10:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574247#M162225</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269468"&gt;@Onizuka&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;An alternative approach uses a "non-executable" SET statement in conjunction with selected KEEP= dataset options (where you &lt;EM&gt;can&lt;/EM&gt; use variable lists):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
retain d;
if 0 then set have(keep=b:) have(keep=a:);
set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 17 Jul 2019 15:57:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574247#M162225</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-07-17T15:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: Reorder variables with retain, some problem using prefix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574473#M162333</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/269468"&gt;@Onizuka&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An alternative approach uses a "non-executable" SET statement in conjunction with selected KEEP= dataset options (where you &lt;EM&gt;can&lt;/EM&gt; use variable lists):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
retain d;
if 0 then set have(keep=b:) have(keep=a:);
set have;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; , thank you for your answer, I will try your solution too, thanks again ! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 07:34:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Reorder-variables-with-retain-some-problem-using-prefix/m-p/574473#M162333</guid>
      <dc:creator>Onizuka</dc:creator>
      <dc:date>2019-07-18T07:34:04Z</dc:date>
    </item>
  </channel>
</rss>

