<?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: Identify rows with repeat character strings in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843734#M36620</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436991"&gt;@abaker_ca&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p02vuhb5ijuirbn1p7azkyianjd8.htm" target="_blank" rel="noopener"&gt;COUNT function&lt;/A&gt; to count the number of "POS" substrings in variable RESULT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set test;
flag=count(result,'POS','i')&amp;gt;1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The optional&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'i'&lt;/FONT&gt; modifier makes the search case-insensitive so that "pos", "Pos", etc. would be counted as well. The numeric variable FLAG will contain the value 1 or 0 if the inequality &lt;FONT face="courier new,courier"&gt;count(&lt;/FONT&gt;...&lt;FONT face="courier new,courier"&gt;)&amp;gt;1&lt;/FONT&gt; is true or false, respectively.&lt;/P&gt;</description>
    <pubDate>Fri, 11 Nov 2022 09:51:05 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2022-11-11T09:51:05Z</dc:date>
    <item>
      <title>Identify rows with repeat character strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843719#M36618</link>
      <description>&lt;P&gt;I have a simple problem that I can solve in R easily but just can't figure out how to solve in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set where there are numerous diagnostic results concatenated into one long string for each target being identified by the assay.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I simply want to identify subjects that are positive for more than one target.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is an example data set.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data test;&lt;BR /&gt;input subject_id $1-8&lt;BR /&gt;result $11 - 33;&lt;BR /&gt;datalines;&lt;BR /&gt;ABCD0001 A POS B POS C NEG D NEG&lt;BR /&gt;ABCD0002 A POS B NEG C NEG D NEG&lt;BR /&gt;ABCD0003 A NEG B NEG C NEG D NEG&lt;BR /&gt;ABCD0004 A POS B NEG C POS D NEG&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally, I'd write code that would return this data set with a flag for subjects ABCD0001 and ABCD0004 because they are positive for more than one target in the 'result' variable.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for anyone's help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 04:48:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843719#M36618</guid>
      <dc:creator>abaker_ca</dc:creator>
      <dc:date>2022-11-11T04:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Identify rows with repeat character strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843734#M36620</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436991"&gt;@abaker_ca&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lefunctionsref/p02vuhb5ijuirbn1p7azkyianjd8.htm" target="_blank" rel="noopener"&gt;COUNT function&lt;/A&gt; to count the number of "POS" substrings in variable RESULT:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set test;
flag=count(result,'POS','i')&amp;gt;1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The optional&amp;nbsp;&lt;FONT face="courier new,courier"&gt;'i'&lt;/FONT&gt; modifier makes the search case-insensitive so that "pos", "Pos", etc. would be counted as well. The numeric variable FLAG will contain the value 1 or 0 if the inequality &lt;FONT face="courier new,courier"&gt;count(&lt;/FONT&gt;...&lt;FONT face="courier new,courier"&gt;)&amp;gt;1&lt;/FONT&gt; is true or false, respectively.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 09:51:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843734#M36620</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-11-11T09:51:05Z</dc:date>
    </item>
    <item>
      <title>Re: Identify rows with repeat character strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843749#M36621</link>
      <description>&lt;P&gt;To avoid this kind of scenario :&lt;/P&gt;
&lt;P&gt;ABCD0001 APOSA POS BNEGB POS C NEG D NEG&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could try this one :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
input subject_id $ result $20.;
datalines;
ABCD0001 A POS B POS C NEG D NEG
ABCD0002 A POS B NEG C NEG D NEG
ABCD0003 A NEG B NEG C NEG D NEG
ABCD0004 A POS B NEG C POS D NEG
;
run;
data want;
 set test; 
 if findw(result,'POS',' ') ne findw(result,'POS',' ','b') then flag='Y';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Nov 2022 11:45:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843749#M36621</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-11-11T11:45:14Z</dc:date>
    </item>
    <item>
      <title>Re: Identify rows with repeat character strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843760#M36624</link>
      <description>Could the actual target names include the letters "POS"?  For example, could any of these words appear in a target name?&lt;BR /&gt;&lt;BR /&gt;POST&lt;BR /&gt;OPPOSITE&lt;BR /&gt;POSE&lt;BR /&gt;POSTERIOR&lt;BR /&gt;SUPPOSE</description>
      <pubDate>Fri, 11 Nov 2022 12:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843760#M36624</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-11-11T12:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: Identify rows with repeat character strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843826#M36631</link>
      <description>&lt;P&gt;It's unlikely they would. For the most part the string in this variable would be a disease target followed by the pos/neg call for the target (e.g. "Flu A POS").&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Nov 2022 16:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843826#M36631</guid>
      <dc:creator>abaker_ca</dc:creator>
      <dc:date>2022-11-11T16:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Identify rows with repeat character strings</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843857#M36635</link>
      <description>&lt;P&gt;Count the occurrences of ' POS '.&amp;nbsp; You might need to append a space to the string if there is a value that completely fills the variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set test;
  n_positive = count(result||' ',' POS ');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that COUNT() has an optional third argument you can use to make the string comparisons case insensitive.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  n_positive = count(result||' ',' POS ','i');&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Nov 2022 20:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Identify-rows-with-repeat-character-strings/m-p/843857#M36635</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-11T20:30:35Z</dc:date>
    </item>
  </channel>
</rss>

