<?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: If specific character found in string then return string in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446843#M112183</link>
    <description>&lt;P&gt;"spit out" is certainly ambiguous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INDEX function is one way to find single characters anywhere in a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rc = index(string, 'G');&lt;/P&gt;
&lt;P&gt;the variable RC will have a value greater than 0 if G is found. Note that is a case sensitive comparison and would not find "g".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other search functions such as FINDC may also work depending on exact requirements.&lt;/P&gt;</description>
    <pubDate>Mon, 19 Mar 2018 16:13:38 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-03-19T16:13:38Z</dc:date>
    <item>
      <title>If specific character found in string then return string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446841#M112182</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;I have this data set and need to select the observations that have a particular character in the string and then (edit) &lt;STRIKE&gt;spit out&lt;/STRIKE&gt; RETURN the particular&amp;nbsp;string containing that character..&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;For example, if I want the observations containing 'G' &lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;then I'd need to get these: ZGZZX, GZZZZ, HSGZZ. If I wanted the observations containing 'X' then I'd return: ZGZZX&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;Thank you&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data temp;
input string $;
datalines;
ZGZZX
GZZZZ
ZZZZZ
HSGZZ
;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 16:15:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446841#M112182</guid>
      <dc:creator>serrld113</dc:creator>
      <dc:date>2018-03-19T16:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: If specific character found in string then return string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446843#M112183</link>
      <description>&lt;P&gt;"spit out" is certainly ambiguous.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The INDEX function is one way to find single characters anywhere in a string.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;rc = index(string, 'G');&lt;/P&gt;
&lt;P&gt;the variable RC will have a value greater than 0 if G is found. Note that is a case sensitive comparison and would not find "g".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Other search functions such as FINDC may also work depending on exact requirements.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 16:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446843#M112183</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-03-19T16:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: If specific character found in string then return string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446848#M112185</link>
      <description>&lt;P&gt;Thank you, I edited my post to be more clear. I know to use INDEX (I believe the value returned would be the position where the character is found within the string) but I would like for the program to return the actual string where the character was found.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 16:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446848#M112185</guid>
      <dc:creator>serrld113</dc:creator>
      <dc:date>2018-03-19T16:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: If specific character found in string then return string</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446850#M112187</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data want;
Set have;
If find(‘G’, variable)&amp;gt;0;
Run; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Mar 2018 16:24:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-specific-character-found-in-string-then-return-string/m-p/446850#M112187</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-03-19T16:24:25Z</dc:date>
    </item>
  </channel>
</rss>

