<?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: How to find and flag if there are values after a 'certain' value horizontally in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-flag-if-there-are-values-after-a-certain-value/m-p/865228#M341671</link>
    <description>&lt;P&gt;Yes, this works. Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Mar 2023 14:55:33 GMT</pubDate>
    <dc:creator>SP01</dc:creator>
    <dc:date>2023-03-20T14:55:33Z</dc:date>
    <item>
      <title>How to find and flag if there are values after a 'certain' value horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-flag-if-there-are-values-after-a-certain-value/m-p/864895#M341529</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input col1 $ col2 $ col3 $ col4 $ col5 $ col6 $ col7 $ col8 $ col9 $ col10 $;
cards;
PM MM JM MM PM PB . . PM .
PM MM JM MM PM PB JM . . .
PM MM JM MM PM MB PM MM . .
PM MM JM MM PM PM MM MB . .
PM MM JM MM PM PM MM PB . .
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Hello all, I was not clear in my details and goal in my last post. So, I am reposting this again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data look like what I have in 'Have' above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Want:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I need to find and flag records that have any value occurring after 'PB' or 'MB', if there is any non-missing value occurring after values 'PB' or 'MB' horizontally, I want to flag it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;                                        flag 
PM MM JM MM PM PB . . PM .               1
PM MM JM MM PM PB JM . . .               1
PM MM JM MM PM MB PM MM . .              1
PM MM JM MM PM PM MM MB .                0
PM MM JM MM PM PM MM PB .                0&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thank you for your time on this.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Mar 2023 15:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-flag-if-there-are-values-after-a-certain-value/m-p/864895#M341529</guid>
      <dc:creator>SP01</dc:creator>
      <dc:date>2023-03-17T15:46:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and flag if there are values after a 'certain' value horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-flag-if-there-are-values-after-a-certain-value/m-p/865065#M341601</link>
      <description>&lt;P&gt;I below giving you the desired outcome?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile datalines truncover;
  input col1 $ col2 $ col3 $ col4 $ col5 $ col6 $ col7 $ col8 $ col9 $ col10 $;
  datalines;
PM MM JM MM PM PB . . PM .
PM MM JM MM PM PB JM . . .
PM MM JM MM PM MB PM MM . .
PM MM JM MM PM PM MM MB . .
PM MM JM MM PM PM MM PB . .
PB MB
MM JM MM PM PM MM
PM MM JM MM PM PM MM MM . PB
MM MM MM MM PM PM MM MM MM MM
;

data new(drop=_:);
  set have;
  array _cols {*} col:;
  flag=0;
  _flag=0;
  do _i=dim(_cols) to 1 by -1;
    if _cols[_i] in ('MB','PB') then
      do;
        flag=_flag;
        leave;
      end;
    if not missing(_cols[_i]) and _cols[_i] not in ('MB','PB') then _flag=1;
  end;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Patrick_0-1679181368107.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/81748iD24C82185311E6EA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Patrick_0-1679181368107.png" alt="Patrick_0-1679181368107.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Mar 2023 23:16:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-flag-if-there-are-values-after-a-certain-value/m-p/865065#M341601</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-03-18T23:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to find and flag if there are values after a 'certain' value horizontally</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-flag-if-there-are-values-after-a-certain-value/m-p/865228#M341671</link>
      <description>&lt;P&gt;Yes, this works. Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 14:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-and-flag-if-there-are-values-after-a-certain-value/m-p/865228#M341671</guid>
      <dc:creator>SP01</dc:creator>
      <dc:date>2023-03-20T14:55:33Z</dc:date>
    </item>
  </channel>
</rss>

