<?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: Is there a way in SAS to flag if there are certain values after a value across columns? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864563#M341419</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/432452"&gt;@SP01&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;I want to flag all records which end with either 'PB' or 'MB' value and there are no values after them across columns and flag if there are values after 'PB' or 'MB'&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So if I am understanding this and also if you wrote it properly, this is equivalent to creating a flag any time there is a 'PB' or 'MB' regardless of what is after it. Is that what you mean?&lt;/P&gt;</description>
    <pubDate>Thu, 16 Mar 2023 15:10:23 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2023-03-16T15:10:23Z</dc:date>
    <item>
      <title>Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864559#M341417</link>
      <description>&lt;P&gt;Hi all, Here is my current data with ten columns:&lt;/P&gt;
&lt;P&gt;co1 col2 col3 col4 col5 col6 col7 col8 col9 col10&lt;BR /&gt;PM&amp;nbsp; MM&amp;nbsp; JM&amp;nbsp; MM PM&amp;nbsp; &amp;nbsp;PB&amp;nbsp;&lt;BR /&gt;PM&amp;nbsp; MM&amp;nbsp; JM&amp;nbsp; MM PM&amp;nbsp; &amp;nbsp;PB&amp;nbsp; &amp;nbsp;JM&amp;nbsp;&lt;BR /&gt;PM&amp;nbsp; MM&amp;nbsp; JM&amp;nbsp; MM PM&amp;nbsp; MB&amp;nbsp; &amp;nbsp;PM&amp;nbsp; JM&amp;nbsp;&lt;BR /&gt;PM&amp;nbsp; MM&amp;nbsp; JM&amp;nbsp; MM PM&amp;nbsp; PM&amp;nbsp; &amp;nbsp;MM&amp;nbsp; MB&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Goal:&lt;BR /&gt;I want to flag all records which end with either 'PB' or 'MB' value and there are no values after them across columns and flag if there are values after 'PB' or 'MB'&lt;/P&gt;
&lt;P&gt;Any help is appreciated. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 15:02:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864559#M341417</guid>
      <dc:creator>SP01</dc:creator>
      <dc:date>2023-03-16T15:02:38Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864563#M341419</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/432452"&gt;@SP01&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;BR /&gt;I want to flag all records which end with either 'PB' or 'MB' value and there are no values after them across columns and flag if there are values after 'PB' or 'MB'&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So if I am understanding this and also if you wrote it properly, this is equivalent to creating a flag any time there is a 'PB' or 'MB' regardless of what is after it. Is that what you mean?&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 15:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864563#M341419</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-16T15:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864564#M341420</link>
      <description>&lt;P&gt;Hi Miller, I am sorry for the confusion. I want to create a flag when there is any value other than 'PB' or 'MB' after 'PB' or 'MB' across columns.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 15:15:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864564#M341420</guid>
      <dc:creator>SP01</dc:creator>
      <dc:date>2023-03-16T15:15:19Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864565#M341421</link>
      <description>&lt;P&gt;So in your example data, please tell us for each row whether we should set a flag, or not.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 15:21:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864565#M341421</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-16T15:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864575#M341423</link>
      <description>&lt;P&gt;Yes, we should set a flag is there are values other than 'PB' or 'MB' after 'PB' or 'MB' as flag = 1, else flag = 0&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 15:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864575#M341423</guid>
      <dc:creator>SP01</dc:creator>
      <dc:date>2023-03-16T15:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864579#M341424</link>
      <description>&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;please tell us for each row in your example data whether we should set a flag, or not.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 15:36:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864579#M341424</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-03-16T15:36:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864586#M341426</link>
      <description>&lt;P&gt;Yes, we should.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 15:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864586#M341426</guid>
      <dc:creator>SP01</dc:creator>
      <dc:date>2023-03-16T15:44:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864588#M341427</link>
      <description>&lt;P&gt;If I understand your question you could&amp;nbsp; do something like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data one; &lt;BR /&gt;input col1 $ col2 $ col3 $ col4 $ col5 $ col6 $ col7 $ col8 $ col9 $ col10 $; &lt;BR /&gt;cards; &lt;BR /&gt;PM MM JM MM PM PB . . JM . &lt;BR /&gt;PM MM JM MM PM PB JM . . . &lt;BR /&gt;PM MM JM MM PM MB PM JM . . &lt;BR /&gt;PM MM JM MM PM PM MM MB . PB &lt;BR /&gt;PM MM JM MM PM PM MM DB . AB &lt;BR /&gt;; &lt;BR /&gt;&lt;BR /&gt;data new; &lt;BR /&gt;set one; &lt;BR /&gt;flag=0; &lt;BR /&gt;array list(*) col1-col10; &lt;BR /&gt;do i=1 to dim(list); &lt;BR /&gt;if list(i) IN ('PB','MB') then do; &lt;BR /&gt;do j=i to dim(list); &lt;BR /&gt;if list(j) ne ' ' then flag=1; &lt;BR /&gt;end; &lt;BR /&gt;end; &lt;BR /&gt;end; &lt;BR /&gt;drop i J; &lt;BR /&gt;run; &lt;BR /&gt;&lt;BR /&gt;proc print; &lt;BR /&gt;run; &lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 15:48:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864588#M341427</guid>
      <dc:creator>russt_sas</dc:creator>
      <dc:date>2023-03-16T15:48:02Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864602#M341432</link>
      <description>&lt;P&gt;Thank you for the solution. This logic is only flagging records that end with 'PM' or 'MB'&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 16:35:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864602#M341432</guid>
      <dc:creator>SP01</dc:creator>
      <dc:date>2023-03-16T16:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864610#M341436</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/432452"&gt;@SP01&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you for the solution. This logic is only flagging records that end with 'PM' or 'MB'&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which is why &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt; asked for clarification.&lt;/P&gt;
&lt;P&gt;Your initial requirement starts "I want to flag all records which end with either 'PB' or 'MB' value and there are no values after them" which matches the solution.&lt;/P&gt;
&lt;P&gt;Poorly phrased if the actual requirement "is flag if any value is 'PB' or 'MB' "&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 16:44:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864610#M341436</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2023-03-16T16:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864614#M341439</link>
      <description>&lt;P&gt;I agree with this. Going forward, I will try to be more precise.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 17:07:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864614#M341439</guid>
      <dc:creator>SP01</dc:creator>
      <dc:date>2023-03-16T17:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864785#M341484</link>
      <description>&lt;P&gt;So you want to flag the observations where the last-non-missing column is not 'PB' og 'MB'?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think this does it:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;                                                                                                                              
  set have;                                                                                                                             
  flag=scan(catx(' ',of col1-col10),-1) not in('PB','MB');                                                                              
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2023 10:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864785#M341484</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2023-03-17T10:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way in SAS to flag if there are certain values after a value across columns?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864800#M341490</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input col1 $ col2 $ col3 $ col4 $ col5 $ col6 $ col7 $ col8 $ col9 $ col10 $;
cards;
PM MM JM MM PM PB . . JM .
PM MM JM MM PM PB JM . . .
PM MM JM MM PM MB PM JM . .
PM MM JM MM PM PM MM MB . PB
PM MM JM MM PM PM MM DB . AB
;

data new;
set one;
length temp $ 2000;
temp=catx('|',of col:);
if prxmatch('/(JM|PB)$/i',strip(temp)) then flag=1;
 else flag=0;
drop temp;
run;

proc print;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 17 Mar 2023 11:45:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Is-there-a-way-in-SAS-to-flag-if-there-are-certain-values-after/m-p/864800#M341490</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-03-17T11:45:39Z</dc:date>
    </item>
  </channel>
</rss>

