<?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 proc sql select - into with wildcards in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638790#M189972</link>
    <description>&lt;P&gt;How about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input field1 $20.;
datalines;
2017_12on15
2018_12on15
2019_12on12
2020_3on3
;

proc sql noprint; 
   select FIELD1 into :MACRO_VAR separated by "|" 
   from work.HAVE where prxmatch('/\d{4}_\d+on\d+/', FIELD1); 
quit;

%put &amp;amp;MACRO_VAR;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 09 Apr 2020 19:42:06 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2020-04-09T19:42:06Z</dc:date>
    <item>
      <title>Using proc sql select - into with wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638788#M189971</link>
      <description>&lt;P&gt;I have a dataset that has one field where the values are&lt;/P&gt;&lt;P&gt;2017_12on15&lt;/P&gt;&lt;P&gt;2018_12on15&lt;/P&gt;&lt;P&gt;2019_12on12&lt;/P&gt;&lt;P&gt;2020_3on3&lt;/P&gt;&lt;P&gt;and then some other values that&amp;nbsp;don't fit this pattern.&amp;nbsp; I want to select these values into&amp;nbsp;macro variable but I can't seem to get it to work.&lt;/P&gt;&lt;P&gt;Here is what I have that isn't working.&amp;nbsp; Probably something simple that I am missing.&amp;nbsp; Any insight would be appreciated.&lt;/P&gt;&lt;PRE&gt;proc sql noprint; select FIELD1 into :MACRO_VAR separated by "|" from work.HAVE where FIELD1 like '20__\_%on%'; quit;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Apr 2020 19:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638788#M189971</guid>
      <dc:creator>GeorgeBonanza</dc:creator>
      <dc:date>2020-04-09T19:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc sql select - into with wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638790#M189972</link>
      <description>&lt;P&gt;How about&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input field1 $20.;
datalines;
2017_12on15
2018_12on15
2019_12on12
2020_3on3
;

proc sql noprint; 
   select FIELD1 into :MACRO_VAR separated by "|" 
   from work.HAVE where prxmatch('/\d{4}_\d+on\d+/', FIELD1); 
quit;

%put &amp;amp;MACRO_VAR;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Apr 2020 19:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638790#M189972</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2020-04-09T19:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc sql select - into with wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638791#M189973</link>
      <description>This works. Thanks very much.</description>
      <pubDate>Thu, 09 Apr 2020 19:51:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638791#M189973</guid>
      <dc:creator>GeorgeBonanza</dc:creator>
      <dc:date>2020-04-09T19:51:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc sql select - into with wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638802#M189977</link>
      <description>&lt;P&gt;You used underscores instead of % for your wild cards.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;'20%\%on%'&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Apr 2020 21:18:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638802#M189977</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-09T21:18:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc sql select - into with wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638996#M190026</link>
      <description>&lt;P&gt;I appreciate you&amp;nbsp;taking the time to respond.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I thought "_" was the wildcard for a single character so if the pattern always starts "20##_", followed by either 1 or 2 digits, then the word "on", and finally another 1 or&amp;nbsp;2 digits, then wouldn't "__\_" capture the "##" and the underscore in "20##_"?&amp;nbsp; Then I would need to use % because the next piece&amp;nbsp;can be 1 or&amp;nbsp;2 digits, similar to after "on" can be 1 or&amp;nbsp;2 digits.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Putting it all together I thought like '20__\_%on%' would work unless "\_%" is escaping both the underscore and %?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Apr 2020 16:05:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/638996#M190026</guid>
      <dc:creator>GeorgeBonanza</dc:creator>
      <dc:date>2020-04-10T16:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using proc sql select - into with wildcards</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/639546#M190293</link>
      <description>&lt;P&gt;You're correct, I'm wrong on underscores not being wildcards.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473693.htm" target="_blank"&gt;https://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473693.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Apr 2020 18:37:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Using-proc-sql-select-into-with-wildcards/m-p/639546#M190293</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-13T18:37:05Z</dc:date>
    </item>
  </channel>
</rss>

