<?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: Binary Values from nonbinary values in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729529#M227034</link>
    <description>&lt;P&gt;Note that SAS only has two types of variables: floating point numbers and fixed length character strings.&lt;/P&gt;
&lt;P&gt;So I assume by "binary" they mean a numeric variable that just only zero (false) or one (true).&amp;nbsp; Those are the values that SAS will return when it evaluates a boolean expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case you just want to test whether or not&amp;nbsp;&lt;SPAN&gt;AUDITOR_FKEY has one of those four values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  bign = auditor_value in (1:4);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The notation 1:4 is shorthand for the integers from 1 to 4, inclusive.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Sat, 27 Mar 2021 03:27:54 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-03-27T03:27:54Z</dc:date>
    <item>
      <title>Binary Values from nonbinary values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729516#M227023</link>
      <description>&lt;P&gt;I have instructions to do the following:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;The variable AUDITOR_FKEY is coded 1, 2, 3, or 4 for the “Big 4” auditors.&amp;nbsp; Code the binary variable “BIGN” as 1 for “Big 4” auditors, and 0 otherwise.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;However, I've never worked with binary values so I'm unsure how to do this? So far I have an if statement that reads&amp;nbsp;data reg.sorted1; set reg.sorted;&lt;BR /&gt;if auditor_fkey =1 and auditor_fkey =2 and auditor_fkey=3 and auditor_fkey=4 then BIGN = 1;&lt;BR /&gt;else BIGN = 0;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but this also doesn't run the correct values? Advice?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 00:24:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729516#M227023</guid>
      <dc:creator>krg1140</dc:creator>
      <dc:date>2021-03-27T00:24:03Z</dc:date>
    </item>
    <item>
      <title>Re: Binary Values from nonbinary values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729517#M227024</link>
      <description>&lt;P&gt;A better way of doing what you want is this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;BIGN = (if auditor_fkey in (1,2,3,4));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The reason why your version doesn't work is you need to use OR not AND - AND assumes they use all 4 auditors at the same time which is impossible.&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 00:40:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729517#M227024</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2021-03-27T00:40:26Z</dc:date>
    </item>
    <item>
      <title>Re: Binary Values from nonbinary values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729529#M227034</link>
      <description>&lt;P&gt;Note that SAS only has two types of variables: floating point numbers and fixed length character strings.&lt;/P&gt;
&lt;P&gt;So I assume by "binary" they mean a numeric variable that just only zero (false) or one (true).&amp;nbsp; Those are the values that SAS will return when it evaluates a boolean expression.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case you just want to test whether or not&amp;nbsp;&lt;SPAN&gt;AUDITOR_FKEY has one of those four values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  bign = auditor_value in (1:4);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;The notation 1:4 is shorthand for the integers from 1 to 4, inclusive.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 03:27:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729529#M227034</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-03-27T03:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Binary Values from nonbinary values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729590#M227081</link>
      <description>&lt;P&gt;Just for completeness sake, is the value of AUDITOR_FKEY ever missing? As in did you confirm it is never missing?&lt;/P&gt;
&lt;P&gt;If there are missing values do you want to assign 0 for those?&lt;/P&gt;</description>
      <pubDate>Sat, 27 Mar 2021 20:41:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729590#M227081</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-27T20:41:12Z</dc:date>
    </item>
    <item>
      <title>Re: Binary Values from nonbinary values</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729782#M227176</link>
      <description>&lt;P&gt;Because you say you are new to Boolean expressions, I'd say I think you did well enough.&amp;nbsp; Does the instruction imply using ANDs or ORs?&amp;nbsp; I think I would have picked ANDs based on the instructions as well.&amp;nbsp; One thing that could go wrong is if AUDITOR_FKEY was a string variable type rather than numeric, as Tom said.&amp;nbsp; In that case the if statement would look like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  if auditor_fkey ="1" and auditor_fkey ="2" /*...*/
    then BIGN = 1;
    else BIGN = 0;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 29 Mar 2021 13:33:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Binary-Values-from-nonbinary-values/m-p/729782#M227176</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-03-29T13:33:03Z</dc:date>
    </item>
  </channel>
</rss>

