<?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: Proc sql-String matching in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425403#M104795</link>
    <description>&lt;P&gt;but where is to filter rows and i want to filter columns&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jan 2018 21:48:40 GMT</pubDate>
    <dc:creator>riya275</dc:creator>
    <dc:date>2018-01-05T21:48:40Z</dc:date>
    <item>
      <title>Proc SQL - String matching  in column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425385#M104785</link>
      <description>&lt;P&gt;i have a very large dataset with around 200 columns. I want to filter out columns whose names end with july, august and september using proc SQL. How do i do it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;i tried using the string matching functionality -&lt;/P&gt;
&lt;PRE&gt;proc sql;&lt;BR /&gt;create table v as&lt;BR /&gt;select * ,like '%july' , like '%august', like '%september'&lt;BR /&gt;from a6.smb;&lt;BR /&gt;quit;&lt;/PRE&gt;
&lt;P&gt;However this is the wrong code. What is the correct way to do it?&lt;/P&gt;
&lt;P&gt;is there any other way to filer out columns automatically?&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 22:11:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425385#M104785</guid>
      <dc:creator>riya275</dc:creator>
      <dc:date>2018-01-05T22:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql-String matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425392#M104789</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163953"&gt;@riya275&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;i have a very large dataset with around 200 columns. I want to filter out columns which end with july, august and september using proc SQL. How do i do it?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you mean "Columns whose name ends with july or august or september"???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or do you mean columns that have values july or august or september???&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 21:10:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425392#M104789</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-01-05T21:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql-String matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425395#M104791</link>
      <description>&lt;P&gt;In addition to &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;answer. remember Any filtration happens in where clause and you do not have a where clause in your sql code&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 21:18:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425395#M104791</guid>
      <dc:creator>kiranv_</dc:creator>
      <dc:date>2018-01-05T21:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql-String matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425397#M104792</link>
      <description>&lt;P&gt;SAS/SQL doesn't support variable lists, other than "*". You could code the list into a macro variable using dictionary tables, but the simplest way in your case is to type the variable names.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 21:21:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425397#M104792</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-01-05T21:21:11Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql-String matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425403#M104795</link>
      <description>&lt;P&gt;but where is to filter rows and i want to filter columns&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 21:48:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425403#M104795</guid>
      <dc:creator>riya275</dc:creator>
      <dc:date>2018-01-05T21:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql-String matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425404#M104796</link>
      <description>&lt;P&gt;column names that end with july , aug, spet&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jan 2018 21:49:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425404#M104796</guid>
      <dc:creator>riya275</dc:creator>
      <dc:date>2018-01-05T21:49:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL - String matching  in column names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425502#M104823</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transpose data=sashelp.class(obs=0) out=class;
var _all_;
run;
proc sql;
select *
 from class
  where prxmatch('/(ex|ght)$/i',strip(_name_));
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 06 Jan 2018 10:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425502#M104823</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2018-01-06T10:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc sql-String matching</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425509#M104824</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/163953"&gt;@riya275&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;but where is to filter rows and i want to filter columns&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then to filter columns, you need to obtain the column names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this (UNTESTED CODE)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=a6.smb noprint out=_cont_;
run;

/* OBTAIN DESIRED COLUMN NAMES */
proc sql noprint;
    select name into :names separated by ',' from _cont_ where lowcase(name) ? ('july','august','september');
quit;

proc sql;
    create table v as select &amp;amp;names from a6.smb;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Of course, this will find any columns where july or august or september is ANYWHERE in the column name, not just at the end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Having said this, I find it an extremely poor strategy to have month names in your variable names anyway, much better would be to have a column called MONTH which indicates the month of the data, rather than have the month name as part of the variable name. Further, if you use month numbers 1 to 12, you make your life even easier.&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jan 2018 15:09:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-String-matching-in-column-names/m-p/425509#M104824</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-01-06T15:09:27Z</dc:date>
    </item>
  </channel>
</rss>

