<?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: reset flag based on other rows value for a type. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/reset-flag-based-on-other-rows-value-for-a-type/m-p/568663#M160129</link>
    <description>&lt;P&gt;Use a double do loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input type $ Status :$12.;
datalines;
A true
A false
A false
C true
C true
C true
E false
E false
E false
;

data want;
do until(last.type);
  set one;
  by type;
  f = max(f,ifn(status='false',1,0));
  t = max(t,ifn(status='true',1,0));
end;
if f and t
then flag = 'Partial';
else if f
then flag = 'False';
else if t
then flag = 'True';
else flag = 'Undef';
do until (last.type);
  set one;
  by type;
  output;
end;
drop t f;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;type    Status    flag

 A      true      Partial
 A      false     Partial
 A      false     Partial
 C      true      True   
 C      true      True   
 C      true      True   
 E      false     False  
 E      false     False  
 E      false     False  
&lt;/PRE&gt;</description>
    <pubDate>Tue, 25 Jun 2019 09:04:42 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2019-06-25T09:04:42Z</dc:date>
    <item>
      <title>reset flag based on other rows value for a type.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reset-flag-based-on-other-rows-value-for-a-type/m-p/568659#M160125</link>
      <description>&lt;P&gt;I have following dataset. i want to create another flag based on status value by type.&lt;/P&gt;&lt;P&gt;if for a type status=True then Flag should be "true" for all type &amp;amp; if a type contains both true &amp;amp; false value under status then let it be "Partial" and&amp;nbsp;if for a type status=False then Flag should be "Flase" for all type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;data&lt;/SPAN&gt; one&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;

&lt;SPAN class="token keyword"&gt;input&lt;/SPAN&gt; type &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;  Status &lt;SPAN class="token punctuation"&gt;$&lt;/SPAN&gt;&lt;SPAN class="token number"&gt;12&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token datalines"&gt;
&lt;SPAN class="token keyword"&gt;datalines&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;SPAN class="token data string"&gt;
A true&lt;BR /&gt;&lt;BR /&gt;A false

B false

C true

C true

C true

E false

E false

E false

&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/SPAN&gt;

&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 08:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reset-flag-based-on-other-rows-value-for-a-type/m-p/568659#M160125</guid>
      <dc:creator>ASHISH2525</dc:creator>
      <dc:date>2019-06-25T08:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: reset flag based on other rows value for a type.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reset-flag-based-on-other-rows-value-for-a-type/m-p/568663#M160129</link>
      <description>&lt;P&gt;Use a double do loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input type $ Status :$12.;
datalines;
A true
A false
A false
C true
C true
C true
E false
E false
E false
;

data want;
do until(last.type);
  set one;
  by type;
  f = max(f,ifn(status='false',1,0));
  t = max(t,ifn(status='true',1,0));
end;
if f and t
then flag = 'Partial';
else if f
then flag = 'False';
else if t
then flag = 'True';
else flag = 'Undef';
do until (last.type);
  set one;
  by type;
  output;
end;
drop t f;
run;

proc print data=want noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;type    Status    flag

 A      true      Partial
 A      false     Partial
 A      false     Partial
 C      true      True   
 C      true      True   
 C      true      True   
 E      false     False  
 E      false     False  
 E      false     False  
&lt;/PRE&gt;</description>
      <pubDate>Tue, 25 Jun 2019 09:04:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reset-flag-based-on-other-rows-value-for-a-type/m-p/568663#M160129</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-25T09:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: reset flag based on other rows value for a type.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/reset-flag-based-on-other-rows-value-for-a-type/m-p/568674#M160138</link>
      <description>&lt;P&gt;Thank you Kurt !&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It worked.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ashish&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 09:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/reset-flag-based-on-other-rows-value-for-a-type/m-p/568674#M160138</guid>
      <dc:creator>ASHISH2525</dc:creator>
      <dc:date>2019-06-25T09:47:56Z</dc:date>
    </item>
  </channel>
</rss>

