<?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 find variable value in string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525323#M142935</link>
    <description>&lt;P&gt;I would like to check if a variable value is in a string. if so, return the position or a boolean value. For example, the variable Student takes 1 of the following values: Mary, Mike, Luke.&amp;nbsp; If the value of this variable is in the list &amp;amp;pass_students then the variable Rank takes the value of the position of that student in the string.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pass_student = Mary Daniel Luke Adam Eva;&lt;BR /&gt;data WORK.CLASS(label='Student Data');&lt;BR /&gt; infile datalines dsd truncover;&lt;BR /&gt; input student:$8.;&lt;BR /&gt; datalines;&lt;BR /&gt; Mary &lt;BR /&gt; Peter &lt;BR /&gt; Luke&lt;BR /&gt; Carol&lt;BR /&gt; Henry&lt;BR /&gt; ;;;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So far, I tried:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class; set class;
	temp="&amp;amp;pass_student.";
	rank= find(student,temp,'t');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Which kinda work, but it is case sensitive. How do I fix this? is there a better way to get what I want?&lt;/P&gt;</description>
    <pubDate>Tue, 08 Jan 2019 05:35:41 GMT</pubDate>
    <dc:creator>somebody</dc:creator>
    <dc:date>2019-01-08T05:35:41Z</dc:date>
    <item>
      <title>find variable value in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525323#M142935</link>
      <description>&lt;P&gt;I would like to check if a variable value is in a string. if so, return the position or a boolean value. For example, the variable Student takes 1 of the following values: Mary, Mike, Luke.&amp;nbsp; If the value of this variable is in the list &amp;amp;pass_students then the variable Rank takes the value of the position of that student in the string.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pass_student = Mary Daniel Luke Adam Eva;&lt;BR /&gt;data WORK.CLASS(label='Student Data');&lt;BR /&gt; infile datalines dsd truncover;&lt;BR /&gt; input student:$8.;&lt;BR /&gt; datalines;&lt;BR /&gt; Mary &lt;BR /&gt; Peter &lt;BR /&gt; Luke&lt;BR /&gt; Carol&lt;BR /&gt; Henry&lt;BR /&gt; ;;;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;So far, I tried:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class; set class;
	temp="&amp;amp;pass_student.";
	rank= find(student,temp,'t');
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Which kinda work, but it is case sensitive. How do I fix this? is there a better way to get what I want?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 05:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525323#M142935</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-01-08T05:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: find variable value in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525325#M142937</link>
      <description>&lt;P&gt;The 'i' switch allows for case insensitive searches. Also as you're searching for words I'd be using findw() instead of find().&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pass_student = Mary Daniel Luke Adam Eva;
data class; 
  set class;
	rank= findw(student,"&amp;amp;pass_student.",'it');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jan 2019 05:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525325#M142937</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-01-08T05:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: find variable value in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525328#M142939</link>
      <description>&lt;P&gt;Hi, this does not work. rank returns 0 for all obs&lt;/P&gt;</description>
      <pubDate>Tue, 08 Jan 2019 05:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525328#M142939</guid>
      <dc:creator>somebody</dc:creator>
      <dc:date>2019-01-08T05:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: find variable value in string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525366#M142963</link>
      <description>&lt;P&gt;Then your initial code never worked.&lt;/P&gt;
&lt;P&gt;I've now changed the this in below code using variable &lt;EM&gt;student&lt;/EM&gt; as 2nd parameter to the function.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
  student='Daniel'; output;
  student='Alfred'; output;
  student='Luke'; output;
  stop;
run;

%let pass_student = Mary Daniel Luke Adam Eva;
data class; 
  set class;
	rank= find("&amp;amp;pass_student.",student,'it');
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 08 Jan 2019 10:01:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/find-variable-value-in-string/m-p/525366#M142963</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-01-08T10:01:12Z</dc:date>
    </item>
  </channel>
</rss>

