<?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: Using conditional OR statement in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797177#M33038</link>
    <description>&lt;P&gt;Try to put ";" at the end of statement "&lt;SPAN&gt;NewVar = 0".&amp;nbsp;Tell us if it worked.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Feb 2022 09:34:43 GMT</pubDate>
    <dc:creator>marceloleme</dc:creator>
    <dc:date>2022-02-18T09:34:43Z</dc:date>
    <item>
      <title>Using conditional OR statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797153#M33034</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a new variable based on a set of other catagorical variables (all var are numerical; 1/0).&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to tag the new var as 1 if multiple other variables are also tagged as one. Else they are 0. I am trying to use the OR operator.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Data Want;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set Have;&amp;nbsp;&lt;/P&gt;&lt;P&gt;NewVar = 0 /* Intialize var */&lt;/P&gt;&lt;P&gt;if var1 = 1 or var2 =1 or var3= 1 then NewVar = 1;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Run;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is not working so far. I have tried using () around the variables and using the | operator.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 06:55:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797153#M33034</guid>
      <dc:creator>pbhatt</dc:creator>
      <dc:date>2022-02-18T06:55:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using conditional OR statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797157#M33035</link>
      <description>&lt;P&gt;Please post the complete log of your step by copy/pasting it into a window opened with this button:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/54552i914D97BE1B0F21E5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" alt="Bildschirmfoto 2020-04-07 um 08.32.59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 07:02:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797157#M33035</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-18T07:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using conditional OR statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797159#M33036</link>
      <description>Try:&lt;BR /&gt;&lt;BR /&gt;if sum(var1, var2, var3) &amp;gt; 1 then newvar = 1;&lt;BR /&gt;else newvar = 0; &lt;BR /&gt;</description>
      <pubDate>Fri, 18 Feb 2022 07:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797159#M33036</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2022-02-18T07:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Using conditional OR statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797177#M33038</link>
      <description>&lt;P&gt;Try to put ";" at the end of statement "&lt;SPAN&gt;NewVar = 0".&amp;nbsp;Tell us if it worked.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 09:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797177#M33038</guid>
      <dc:creator>marceloleme</dc:creator>
      <dc:date>2022-02-18T09:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Using conditional OR statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797178#M33039</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4954"&gt;@Astounding&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Try:&lt;BR /&gt;&lt;BR /&gt;if sum(var1, var2, var3) &amp;gt; 1 then newvar = 1;&lt;BR /&gt;else newvar = 0; &lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Or even shorter:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Newvar = (sum(var1,var2,var3)&amp;gt;1);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sum with give the number of variables with 1 as the value&lt;/P&gt;
&lt;P&gt;Some things that may help with possibly related code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Min(var1,var2,var3) = 0 ; At least one 0 in the variables (even if some are missing)&lt;/P&gt;
&lt;P&gt;Min(var1,var2,var3) = 1; &amp;nbsp; means All non-missing variables are 1.&lt;/P&gt;
&lt;P&gt;Max(var1, var2,var3)=0;&amp;nbsp; means all non-missing are 0&lt;/P&gt;
&lt;P&gt;Max(var1, var2,var3)=1;&amp;nbsp; means at least one non-missing is 1&lt;/P&gt;
&lt;P&gt;Range(var1,var2,var3)=0;&amp;nbsp; means all non-missing are the same, possibly all 1 or all 0 but the same.&lt;/P&gt;
&lt;P&gt;Range(var1,var2,var3)=1; means at least one 1 and at least one 0.&lt;/P&gt;
&lt;P&gt;N(var1,var2,var3) to get number of non-missing values&lt;/P&gt;
&lt;P&gt;Nmiss(var1,var2,var3) to get number of missing values&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 09:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797178#M33039</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-02-18T09:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using conditional OR statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797360#M33043</link>
      <description>The ";" typo was by accident, but yes I did try that.&lt;BR /&gt;That was not the issue.&lt;BR /&gt;</description>
      <pubDate>Sat, 19 Feb 2022 05:11:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797360#M33043</guid>
      <dc:creator>pbhatt</dc:creator>
      <dc:date>2022-02-19T05:11:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using conditional OR statement</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797361#M33044</link>
      <description>Thank you so much for your detailed response! I will make sure to keep track of these commands for future use!</description>
      <pubDate>Sat, 19 Feb 2022 05:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Using-conditional-OR-statement/m-p/797361#M33044</guid>
      <dc:creator>pbhatt</dc:creator>
      <dc:date>2022-02-19T05:12:50Z</dc:date>
    </item>
  </channel>
</rss>

