<?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: Update in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539697#M148752</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132373"&gt;@nid197&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;This solution is working fine.&lt;BR /&gt;&lt;STRONG&gt;Just the problem is I need final_flag 'Y' if 'Y' is there in any of the flag(no matter how many N are there)&lt;/STRONG&gt;&lt;BR /&gt;And final_flag will be no only if all the flags are 'N' .&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132373"&gt;@nid197&lt;/a&gt;&amp;nbsp; &amp;nbsp;Sir./mam.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Just the problem is I need final_flag 'Y' if 'Y' is there in any of the flag(no matter how many N are there)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;That's exactly what my solution does . Kindly test plz&lt;/P&gt;</description>
    <pubDate>Fri, 01 Mar 2019 17:05:48 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2019-03-01T17:05:48Z</dc:date>
    <item>
      <title>Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539603#M148711</link>
      <description>Hi I want to check each row in flag1-flag10 and update a final_final-&lt;BR /&gt;&lt;BR /&gt;Accn flag1 flag2 flag3 flag4 flag 5 final_flag&lt;BR /&gt;123 y y y n n y&lt;BR /&gt;573 n n n n n n&lt;BR /&gt;962 n n y n n y&lt;BR /&gt;&lt;BR /&gt;I.e from flag1 to flag5 (n) if i get any y then final_flag= y else if all n then only final_flag=n&lt;BR /&gt;&lt;BR /&gt;Can anyone help?</description>
      <pubDate>Fri, 01 Mar 2019 12:50:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539603#M148711</guid>
      <dc:creator>nid197</dc:creator>
      <dc:date>2019-03-01T12:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539611#M148714</link>
      <description>&lt;P&gt;You can use the WHICHC function. There is an example in the documentation.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0jfvenvsqk24vn1q2ypospoq9ij.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?cdcId=pgmmvacdc&amp;amp;cdcVersion=9.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=p0jfvenvsqk24vn1q2ypospoq9ij.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 13:36:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539611#M148714</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-01T13:36:13Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539619#M148719</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (Accn flag1 flag2 flag3 flag4 flag5) (: $3.) ;
cards;
123 y y y n n y
573 n n n n n n
962 n n y n n y
;

data want;
set have;
array f(*) flag:;
final_flag='n';
if 'y' in f then final_flag='y';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 01 Mar 2019 14:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539619#M148719</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T14:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539626#M148723</link>
      <description>There is an old function VERIFY() which is useful for checking the existence of specific characters.... like&lt;BR /&gt;if verify( cats( of flag:), "yY")  then final_flag ="y" ;&lt;BR /&gt;&lt;BR /&gt;VERIFY() operates on a single string, seeking the first occurrence of any character in the second parameter of tge function and returns 0 if none are found. It is case sensitive,  so providing both upper and lower y makes the search case-insensitive. &lt;BR /&gt;The CATS() function returns a concatenation of the flagN vars. It requires a list of the variables to concatenate - the " of flag:" works neatly to achieve that.&lt;BR /&gt;&lt;BR /&gt;One way this VERIFY() approach might fail, arises when the flags contain other strings than just  a y or n - for example , if a flag var holds the 3 chars "MAY" then that Y would result in final_flag set to y</description>
      <pubDate>Fri, 01 Mar 2019 14:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539626#M148723</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2019-03-01T14:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539628#M148724</link>
      <description>Didn't expect to see a smiley icon.&lt;BR /&gt;What was intended there&lt;BR /&gt;"flag:"&lt;BR /&gt;without these quotes</description>
      <pubDate>Fri, 01 Mar 2019 14:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539628#M148724</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2019-03-01T14:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539690#M148748</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;This solution is working fine.&lt;BR /&gt;Just the problem is I need final_flag 'Y' if 'Y' is there in any of the flag(no matter how many N are there)&lt;BR /&gt;And final_flag will be no only if all the flags are 'N' .</description>
      <pubDate>Fri, 01 Mar 2019 16:50:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539690#M148748</guid>
      <dc:creator>nid197</dc:creator>
      <dc:date>2019-03-01T16:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539691#M148749</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15174"&gt;@Peter_C&lt;/a&gt;&lt;BR /&gt;the verify function has error as it does not have enough arguments.</description>
      <pubDate>Fri, 01 Mar 2019 16:52:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539691#M148749</guid>
      <dc:creator>nid197</dc:creator>
      <dc:date>2019-03-01T16:52:27Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539697#M148752</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132373"&gt;@nid197&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/138205"&gt;@novinosrin&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;This solution is working fine.&lt;BR /&gt;&lt;STRONG&gt;Just the problem is I need final_flag 'Y' if 'Y' is there in any of the flag(no matter how many N are there)&lt;/STRONG&gt;&lt;BR /&gt;And final_flag will be no only if all the flags are 'N' .&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/132373"&gt;@nid197&lt;/a&gt;&amp;nbsp; &amp;nbsp;Sir./mam.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Just the problem is I need final_flag 'Y' if 'Y' is there in any of the flag(no matter how many N are there)&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;That's exactly what my solution does . Kindly test plz&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 17:05:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539697#M148752</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2019-03-01T17:05:48Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539738#M148766</link>
      <description>If verify( cats(of flag: ), 'yY' )  then final_flag = 'Y'  ;&lt;BR /&gt;</description>
      <pubDate>Fri, 01 Mar 2019 18:40:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539738#M148766</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2019-03-01T18:40:11Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539805#M148809</link>
      <description>&lt;P&gt;Another example where using actual binary numeric values instead of characters for y and n work much easier.&lt;/P&gt;
&lt;P&gt;If 1 = Y and 0 = n&lt;/P&gt;
&lt;P&gt;then:&lt;/P&gt;
&lt;PRE&gt;data have;
   input Accn flag1 flag2 flag3 flag4 flag5 ;
   final_flag= (max(of flag:)=1);
datalines;
123 1 1 1 0 0
573 0 0 0 0 0
962 0 0 1 0 0
;
run;&lt;/PRE&gt;
&lt;P&gt;Add 27 more "flag" variables and the code doesn't need a change.&lt;/P&gt;
&lt;P&gt;Some additional bits: The mean of any of the flag variables would be the percent, in decimal form, of Yes values; the sum of the variable would be the number of Yes values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And 1 / 0 are natural results of any logical comparison in SAS, as shown above.&lt;/P&gt;
&lt;P&gt;If you must see text of Y or N then a custom format to display Y for 1 and N for 0 is pretty trivial (I have several versions depending on what is needed with missing or special missing values).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to know if all of the values are the same : if range( of flag:) = 0.&lt;/P&gt;
&lt;P&gt;If you want to know if all of the values are 0 : if sum(of flag: )= 0 ;&lt;/P&gt;
&lt;P&gt;If you want to know if all of the values are&amp;nbsp;1 : if sum(of flag: ) = n(of flag:) which adjusts for missing until all are missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can even test such as if a percentage of values are 1: if mean(of flag:) &amp;gt; 0.5 (more than half for example)&lt;/P&gt;
&lt;P&gt;If want to know if a&amp;nbsp;number of values were yes such as 3 to 5: if 3 le sum( of flag:) le 5.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So many things that get to be obnoxious with Y/N, T/F or other character coding.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 23:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539805#M148809</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-03-01T23:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Update</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539815#M148814</link>
      <description>&lt;P&gt;Here one way to go:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  input Accn $3. (flag1 flag2 flag3 flag4 flag5) (: $upcase1.) ;
cards;
123 y y y n n y
573 n n n n n n
962 n n y n n y
;
run;

data want;
  set have;
  final_flag=ifc(whichc('Y',of flag:),'Y','N');
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 02 Mar 2019 00:27:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Update/m-p/539815#M148814</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2019-03-02T00:27:50Z</dc:date>
    </item>
  </channel>
</rss>

