<?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: Filtering columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281968#M57240</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the sequence is in the middle of the character name you can select those variable in a macro statement &lt;STRONG&gt;separated by space &lt;/STRONG&gt;and&lt;/P&gt;
&lt;P&gt;use this macro variable in a &lt;STRONG&gt;keep &lt;/STRONG&gt;statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For doing this operation you shall use the dictionary table - &lt;STRONG&gt;vcolumn:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select name into :vr separated by ' '
from sashelp.vcolumn
where libname eq 'SASHELP' and memname eq 'CLASS'
and name like '%h%';
quit;

data want;
set sashelp.class;
keep &amp;amp;vr;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 04 Jul 2016 09:16:12 GMT</pubDate>
    <dc:creator>Loko</dc:creator>
    <dc:date>2016-07-04T09:16:12Z</dc:date>
    <item>
      <title>Filtering columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281964#M57237</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a big data set with more than 4000 columns and need to keep columns that have specific sequence of characters in their name (e.g. "_US_"). Can I that using wildcards in "Keep" statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2016 08:27:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281964#M57237</guid>
      <dc:creator>VanDalucas</dc:creator>
      <dc:date>2016-07-04T08:27:43Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281965#M57238</link>
      <description>If they start with the same sequence of characters you could say something like _US_:.&lt;BR /&gt;If they are all together in the dataset you could say "all variables between X and Y" with X--Y.</description>
      <pubDate>Mon, 04 Jul 2016 08:36:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281965#M57238</guid>
      <dc:creator>arodriguez</dc:creator>
      <dc:date>2016-07-04T08:36:14Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281968#M57240</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the sequence is in the middle of the character name you can select those variable in a macro statement &lt;STRONG&gt;separated by space &lt;/STRONG&gt;and&lt;/P&gt;
&lt;P&gt;use this macro variable in a &lt;STRONG&gt;keep &lt;/STRONG&gt;statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For doing this operation you shall use the dictionary table - &lt;STRONG&gt;vcolumn:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select name into :vr separated by ' '
from sashelp.vcolumn
where libname eq 'SASHELP' and memname eq 'CLASS'
and name like '%h%';
quit;

data want;
set sashelp.class;
keep &amp;amp;vr;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 04 Jul 2016 09:16:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281968#M57240</guid>
      <dc:creator>Loko</dc:creator>
      <dc:date>2016-07-04T09:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281970#M57241</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On a similar pattern as per&amp;nbsp;@Loko suggestion:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc contents data=have out=vars(keep=name);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;select name into :vars_needed separated by ' '&lt;BR /&gt;from vars&lt;BR /&gt;where find(name,"_US_")&amp;gt;0;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;vars_needed;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2016 09:31:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281970#M57241</guid>
      <dc:creator>stat_sas</dc:creator>
      <dc:date>2016-07-04T09:31:59Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281993#M57251</link>
      <description>&lt;P&gt;I really thank all of you for you replies,&lt;/P&gt;&lt;P&gt;The solution using proc sql worked fine,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(I was just wondering if a more ''complex'' KEEP statement could do the job but it seems there is no such possibility)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jul 2016 13:27:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/281993#M57251</guid>
      <dc:creator>VanDalucas</dc:creator>
      <dc:date>2016-07-04T13:27:03Z</dc:date>
    </item>
    <item>
      <title>Re: Filtering columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/282008#M57256</link>
      <description>Having 4000 columns is usually not a very user/programming friendly structure. You'll probably encounter other similar problems down the road. &lt;BR /&gt;Consider transposing your data to long format, then you'll be able to do more clever things with simpler filtering and grouping.</description>
      <pubDate>Mon, 04 Jul 2016 14:29:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Filtering-columns/m-p/282008#M57256</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-07-04T14:29:16Z</dc:date>
    </item>
  </channel>
</rss>

