<?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 - using CONTAINS and Variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337760#M76765</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you post example data in the form of a datastep and your code.&lt;/P&gt;
&lt;P&gt;Using a variable for the matched substring should not be a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input str1 $10. str2 $8.;
	datalines;
impossiblepossible
;
run;

proc sql;
	CREATE TABLE want AS
	SELECT *
	FROM have
	WHERE str1 CONTAINS str2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 03 Mar 2017 09:59:52 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2017-03-03T09:59:52Z</dc:date>
    <item>
      <title>PROC SQL - using CONTAINS and Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337758#M76764</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is it possible to use a variable instead of a string for the CONTAINS operator?&lt;/P&gt;&lt;P&gt;If t1.NAME contains the string of t2.Origin, the variable Type should contain Pickup.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE WHEN t1.NAME CONTAINS t2.Origin THEN 'Pickup' ELSE 'Not Defined' END AS Type&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;t1.NAME looks like this: "Night/Weekend/Holidaysurcharge (Munich)"&lt;/P&gt;&lt;P&gt;t2.Origin = "Munich"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I allready tried this, but that doesnt work either:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE WHEN t1.NAME CONTAINS CAT(t2.Origin) THEN 'Pickup' ELSE 'Not Defined' END AS Type&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is this even possible?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best regards&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Dirk&lt;/SPAN&gt;&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;</description>
      <pubDate>Fri, 03 Mar 2017 10:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337758#M76764</guid>
      <dc:creator>dirks</dc:creator>
      <dc:date>2017-03-03T10:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - using CONTAINS and Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337760#M76765</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you post example data in the form of a datastep and your code.&lt;/P&gt;
&lt;P&gt;Using a variable for the matched substring should not be a problem.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input str1 $10. str2 $8.;
	datalines;
impossiblepossible
;
run;

proc sql;
	CREATE TABLE want AS
	SELECT *
	FROM have
	WHERE str1 CONTAINS str2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Mar 2017 09:59:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337760#M76765</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2017-03-03T09:59:52Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - using CONTAINS and Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337761#M76766</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case
  when index(t1.name,strip(t2.origin)) &amp;gt; 0
  then 'Pickup'
  else 'Not Defined'
end as type&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;if the contains operator does not allow variables.&lt;/P&gt;
&lt;P&gt;Always keep in mind that SAS character variables have a defined length and will be padded with blanks, so you need to remove those blanks for certain purposes.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 10:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337761#M76766</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-03-03T10:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - using CONTAINS and Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337772#M76775</link>
      <description>&lt;P&gt;You need STRIP() for CONTAINS&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;CASE WHEN t1.NAME CONTAINS &amp;nbsp;STRIP( t2.Origin )&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 Mar 2017 10:32:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337772#M76775</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-03-03T10:32:46Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL - using CONTAINS and Variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337773#M76776</link>
      <description>&lt;P&gt;Thank you. I did not know this...&lt;/P&gt;&lt;P&gt;If I click into the output, there where no blanks. But they seem to exist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;CASE WHEN t1.NAME CONTAINS CAT(TRIM(t1.Origin)) THEN 'Pickup'
WHEN  t1.NAME CONTAINS CAT(TRIM(t1.Destination)) THEN 'Delivery'
ELSE 'Not Defined' END&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 03 Mar 2017 10:38:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-SQL-using-CONTAINS-and-Variables/m-p/337773#M76776</guid>
      <dc:creator>dirks</dc:creator>
      <dc:date>2017-03-03T10:38:54Z</dc:date>
    </item>
  </channel>
</rss>

