<?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: Using column wildcard (:) with retain statement in a datastep in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338450#M264956</link>
    <description>&lt;P&gt;Here is the reason why you cannot use : wildcard in a retain statement intended to re-order variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The : wildcard only works with variables AFTER they are already defined.&lt;/P&gt;
&lt;P&gt;Using RETAIN to reorder variables requires that the RETAIN statement appear BEFORE the variables are defined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2017 14:18:25 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-03-06T14:18:25Z</dc:date>
    <item>
      <title>Using column wildcard (:) with retain statement in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/178637#M264952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a datastep where I need to use a retain statement to reorder variables. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When using the column wildcard, it will reorder my columns in a different way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is variables wil vary from one week to another. I might end up with 12 account numbers one week and only 3 the following one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I make that work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please see attached&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 15:15:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/178637#M264952</guid>
      <dc:creator>Niala</dc:creator>
      <dc:date>2014-05-30T15:15:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using column wildcard (:) with retain statement in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/178638#M264953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need to put the RETAIN statement before the SET statement.&amp;nbsp; The order of variables cannot be changed once the SET statement has been read, in your example even the expected code is wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2014 15:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/178638#M264953</guid>
      <dc:creator>Keith</dc:creator>
      <dc:date>2014-05-30T15:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Using column wildcard (:) with retain statement in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338372#M264954</link>
      <description>&lt;P&gt;Anyway:&amp;nbsp;retain with wildcard ( colon ) does not work....:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
file _webout;
  length _out $2000.;
  retain PE12: PE3: IE12: IE3: Z1 0;
  set progdata2 end=eof;
  if _N_ eq 1 then do;&lt;BR /&gt;......&lt;BR /&gt;run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;gives an EMPTY result set, but&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
file _webout;
  length _out $2000.;
  retain PE12_1-PE12_99 PE3: IE12: IE3: Z1 0;
  set progdata2 end=eof;
  if _N_ eq 1 then do;
.....
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;gives correct data (as expected for variables PE12_1.....PE12_12)&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Rest of code and data unchanged&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;???????&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 08:17:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338372#M264954</guid>
      <dc:creator>defaz</dc:creator>
      <dc:date>2017-03-06T08:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using column wildcard (:) with retain statement in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338445#M264955</link>
      <description>&lt;P&gt;Use PROC SQL to write out your retain statement for you. e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data ds01;
  input acct1 $6. acct2 $6. custno $4. email1 $16. email2 $16. address  $16. city $16.;
  datalines;
1234561405680001a@a.com         b@a.com         123 First St    NYC             
8518596165610002n@b.com         r@b.com         1563 2nd St     Chicago         
6641691008540003m@c.com         g@c.com         1986 3rd st     San Francisco   
;
run;

proc sql noprint;
  select name into :retains separated by ' '
    from dictionary.columns
      where libname=upcase('work') and
            memname=upcase('ds01') and
            (name like 'email%' or name like 'acct%')
        order by name
  ;
quit;

data ds02_expected;
  retain custno address city &amp;amp;retains.;
  set ds01;
run;
&lt;/PRE&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 14:11:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338445#M264955</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-03-06T14:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using column wildcard (:) with retain statement in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338450#M264956</link>
      <description>&lt;P&gt;Here is the reason why you cannot use : wildcard in a retain statement intended to re-order variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The : wildcard only works with variables AFTER they are already defined.&lt;/P&gt;
&lt;P&gt;Using RETAIN to reorder variables requires that the RETAIN statement appear BEFORE the variables are defined.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 14:18:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338450#M264956</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-03-06T14:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using column wildcard (:) with retain statement in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338677#M264957</link>
      <description>&lt;P&gt;thank you, I&amp;nbsp;just tried to avoid those workarounds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 05:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338677#M264957</guid>
      <dc:creator>defaz</dc:creator>
      <dc:date>2017-03-07T05:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Using column wildcard (:) with retain statement in a datastep</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338679#M264958</link>
      <description>thank you. Now it's clear. I searched for "SAS variables Wildcard" and in none of the results is a hint like this</description>
      <pubDate>Tue, 07 Mar 2017 05:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-column-wildcard-with-retain-statement-in-a-datastep/m-p/338679#M264958</guid>
      <dc:creator>defaz</dc:creator>
      <dc:date>2017-03-07T05:22:25Z</dc:date>
    </item>
  </channel>
</rss>

