<?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 call the variables with the same 3 last letters in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271874#M54081</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;there are some variables in my dataset that have the same name at the last 3 letters.&lt;/P&gt;
&lt;P&gt;For example: &amp;nbsp;ABC_123, BCD_123, CBB_123, GHJ_123, --- and more&lt;/P&gt;
&lt;P&gt;I wonder how to code the simple way in the "keep" statement in order to keep all the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set data (keep = :123 ); -- I try to do this, but it did not work.&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if only a small amount of variable, I defenitely can just write the full name of the variable (keep=ABC_123 BCD_123), but if I want more variables with the same 3 last letters, the "keep" statement will be very long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is it a way to simplify the code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can anyone show me how to code it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much in advance.&lt;/P&gt;</description>
    <pubDate>Fri, 20 May 2016 01:38:48 GMT</pubDate>
    <dc:creator>ursula</dc:creator>
    <dc:date>2016-05-20T01:38:48Z</dc:date>
    <item>
      <title>call the variables with the same 3 last letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271874#M54081</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;there are some variables in my dataset that have the same name at the last 3 letters.&lt;/P&gt;
&lt;P&gt;For example: &amp;nbsp;ABC_123, BCD_123, CBB_123, GHJ_123, --- and more&lt;/P&gt;
&lt;P&gt;I wonder how to code the simple way in the "keep" statement in order to keep all the variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;set data (keep = :123 ); -- I try to do this, but it did not work.&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if only a small amount of variable, I defenitely can just write the full name of the variable (keep=ABC_123 BCD_123), but if I want more variables with the same 3 last letters, the "keep" statement will be very long.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is it a way to simplify the code?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;can anyone show me how to code it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much in advance.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 01:38:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271874#M54081</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2016-05-20T01:38:48Z</dc:date>
    </item>
    <item>
      <title>Re: call the variables with the same 3 last letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271877#M54082</link>
      <description>&lt;P&gt;SAS data step language doesn't have syntax to create variable lists from name suffixes. However, if your variables appear consecutively in the dataset variable list, you can use a list such as ABC_123 -- GHJ_123 which means &lt;EM&gt;all the variables between ABC_123 and GHJ_123&lt;/EM&gt;. Note the double dashes between the first and last variable names.&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 02:34:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271877#M54082</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-05-20T02:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: call the variables with the same 3 last letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271883#M54084</link>
      <description>&lt;P&gt;No SAS syntax for this, the usual way is to extract the names :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
   select NAME into :var_list separated by ' '
    from dictionary.COLUMNS 
    where LIBNAME ='MYLIB' 
      and MEMNAME ='MYTAB'
      and strip(NAME) like '%123';
quit;                 
data WANT;
  set MYLIB.MYTAB(keep= &amp;amp;var_list);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Be careful about the case if your suffix is alphabetical.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 03:56:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271883#M54084</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2016-05-20T03:56:49Z</dc:date>
    </item>
    <item>
      <title>Re: call the variables with the same 3 last letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271897#M54085</link>
      <description>Thank you for the good idea. &lt;BR /&gt;I think I can group them together first and then run the code&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;</description>
      <pubDate>Fri, 20 May 2016 05:11:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271897#M54085</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2016-05-20T05:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: call the variables with the same 3 last letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271898#M54086</link>
      <description>Thank you chris for the code. This is a good option too.</description>
      <pubDate>Fri, 20 May 2016 05:13:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271898#M54086</guid>
      <dc:creator>ursula</dc:creator>
      <dc:date>2016-05-20T05:13:55Z</dc:date>
    </item>
    <item>
      <title>Re: call the variables with the same 3 last letters</title>
      <link>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271903#M54088</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have a look at this blog entry &lt;A href="http://blogs.sas.com/content/sastraining/2011/11/18/jedi-sas-tricks-building-a-name-suffix-variable-list/" target="_blank"&gt;http://blogs.sas.com/content/sastraining/2011/11/18/jedi-sas-tricks-building-a-name-suffix-variable-list/&lt;/A&gt; by &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13728"&gt;@SASJedi﻿&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please make sure you also read the comments.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bruno&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2016 06:02:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/call-the-variables-with-the-same-3-last-letters/m-p/271903#M54088</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2016-05-20T06:02:18Z</dc:date>
    </item>
  </channel>
</rss>

