<?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: Ne comparson operator resulting in all observations = 1 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/397022#M95927</link>
    <description>&lt;P&gt;Yes, it seemed all that was needed was to change 'or' to 'and'.&lt;BR /&gt;Thanks for the help!&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2017 07:14:18 GMT</pubDate>
    <dc:creator>senac255</dc:creator>
    <dc:date>2017-09-19T07:14:18Z</dc:date>
    <item>
      <title>Ne comparson operator resulting in all observations = 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/396283#M95659</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;I am attempting to create a new dataset in which a new ethnicity variable 'nonmapac' is derived. This variable will eventually be used for comparisons. &amp;nbsp;However, when I run the program, all the observations = 1 (which is not the case). I'm not sure where I am going wrong. The code is as below:&lt;BR /&gt;&lt;BR /&gt;data new;&lt;BR /&gt;set primhd.clients;&lt;BR /&gt;nonmapac=0;&lt;BR /&gt;if ethnicgp ne 21&lt;BR /&gt;or ethnicg1 ne 21&lt;BR /&gt;or ethnicg2 ne 21&lt;BR /&gt;or ethnicg3 ne 21&lt;BR /&gt;or ethnicgp ne 30&lt;BR /&gt;or ethnicg1 ne 30&lt;BR /&gt;or ethnicg2 ne 30&lt;BR /&gt;or ethnicg3 ne 30&lt;BR /&gt;or ethnicgp ne 31&lt;BR /&gt;or ethnicg1 ne 31&lt;BR /&gt;or ethnicg2 ne 31&lt;BR /&gt;or ethnicg3 ne 31&lt;BR /&gt;or ethnicgp ne 32&lt;BR /&gt;or ethnicg1 ne 32&lt;BR /&gt;or ethnicg2 ne 32&lt;BR /&gt;or ethnicg3 ne 32&lt;BR /&gt;or ethnicgp ne 33&lt;BR /&gt;or ethnicg1 ne 33&lt;BR /&gt;or ethnicg2 ne 33&lt;BR /&gt;or ethnicg3 ne 33&lt;BR /&gt;or ethnicgp ne 34&lt;BR /&gt;or ethnicg1 ne 34&lt;BR /&gt;or ethnicg2 ne 34&lt;BR /&gt;or ethnicg3 ne 34&lt;BR /&gt;or ethnicgp ne 35&lt;BR /&gt;or ethnicg1 ne 35&lt;BR /&gt;or ethnicg2 ne 35&lt;BR /&gt;or ethnicg3 ne 35&lt;BR /&gt;or ethnicgp ne 36&lt;BR /&gt;or ethnicg1 ne 36&lt;BR /&gt;or ethnicg2 ne 36&lt;BR /&gt;or ethnicg3 ne 36&lt;BR /&gt;or ethnicgp ne 37&lt;BR /&gt;or ethnicg1 ne 37&lt;BR /&gt;or ethnicg2 ne 37&lt;BR /&gt;or ethnicg3 ne 37&lt;BR /&gt;then nonmapac=1;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:46:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/396283#M95659</guid>
      <dc:creator>senac255</dc:creator>
      <dc:date>2017-09-15T11:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Ne comparson operator resulting in all observations = 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/396288#M95660</link>
      <description>&lt;P&gt;You need to think through what conditions should result in 1 vs. 0. &amp;nbsp;Just these two conditions alone will always give you 1:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if ethnicgp ne 21 or ethnicgp ne 30 then nonmapac = 1;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Every observation, regardless of the incoming variables, will get a 1 since one comparison or the other (or both) must be true. &amp;nbsp;It might be as simple as changing OR to AND, or it might be more complex ... it depends on what you are intending as the result.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:52:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/396288#M95660</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-15T11:52:17Z</dc:date>
    </item>
    <item>
      <title>Re: Ne comparson operator resulting in all observations = 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/396289#M95661</link>
      <description>&lt;P&gt;Short (condensed) excerpt from your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if ethnicgp ne 21
or ethnicgp ne 30&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can clearly see that one of those conditions MUST be true, therefore the whole condition will always be true.&lt;/P&gt;
&lt;P&gt;I guess you wanted it to be "and".&lt;/P&gt;
&lt;P&gt;Also see how you can easily simplify the code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if
  ethnicgcp not in(21,30,31,32,33,34,35,36,37) and
  ethnicgcp1 not in(21,30,31,32,33,34,35,36,37) and
  ethnicgcp2 not in(21,30,31,32,33,34,35,36,37) and
  ethnicgcp3 not in(21,30,31,32,33,34,35,36,37)
then nonmapac = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Sep 2017 11:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/396289#M95661</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-09-15T11:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Ne comparson operator resulting in all observations = 1</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/397022#M95927</link>
      <description>&lt;P&gt;Yes, it seemed all that was needed was to change 'or' to 'and'.&lt;BR /&gt;Thanks for the help!&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 07:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Ne-comparson-operator-resulting-in-all-observations-1/m-p/397022#M95927</guid>
      <dc:creator>senac255</dc:creator>
      <dc:date>2017-09-19T07:14:18Z</dc:date>
    </item>
  </channel>
</rss>

