<?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 and usage in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510866#M137489</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154084"&gt;@capam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Case 2 produces correct output when followed by a format:&lt;BR /&gt;format output binary6.;&lt;BR /&gt;How do I remove the extra zeros on the left. Thanks so much.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you refer to my earlier post where I outlined the two cases. The "decimal output" solution in the more recent post removes the leading zeros by converting the binary numbers to decimal numbers, e.g., the binary 4 (100 in the binary system) is converted to the decimal 100 (one hundred). Alternatively, you could define &lt;FONT face="courier new,courier"&gt;output&lt;/FONT&gt; as a character variable if it's only used for reporting purposes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Character output */

data want;
set have;
output = put(input(put(band(input(put(input1,6.),binary.),input(put(input2,6.),binary.)),binary6.),6.),6.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Nov 2018 19:31:41 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2018-11-06T19:31:41Z</dc:date>
    <item>
      <title>binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510805#M137475</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to use 'band' to solve the following. bitwise AND operator on up to 6 digit binary inputs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The syntax I'm using is:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;set have;&lt;BR /&gt;output = input(put(band(input1,input2),binary6.),6.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The current output is:&lt;BR /&gt;input1 input2 output&lt;BR /&gt;111111 100&amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;BR /&gt;111111 1001&amp;nbsp; &amp;nbsp; 1&lt;BR /&gt;111111 101111 111&lt;BR /&gt;111111 111111 111&lt;BR /&gt;111110 100000 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It should be:&lt;BR /&gt;input1 input2&amp;nbsp; &amp;nbsp;output&lt;BR /&gt;111111 100&amp;nbsp; &amp;nbsp; &amp;nbsp; 100&lt;BR /&gt;111111 1001&amp;nbsp; &amp;nbsp; 1001&lt;BR /&gt;111111 101111 101111&lt;BR /&gt;111111 111111&amp;nbsp; 111111&lt;BR /&gt;111110 100000 100000&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 16:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510805#M137475</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2018-11-06T16:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510819#M137477</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154084"&gt;@capam&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you&amp;nbsp;create the original dataset HAVE?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please see below how your code works correctly with &lt;EM&gt;my&lt;/EM&gt; dataset HAVE:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (input1 input2) (:binary.);
format input: binary6.;
cards;
111111 100
111111 1001
111111 101111
111111 111111
111110 100000
;

data have;
set have;
output = input(put(band(input1,input2),binary6.),6.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;input1    input2    output

111111    000100       100
111111    001001      1001
111111    101111    101111
111111    111111    111111
111110    100000    100000&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Nov 2018 16:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510819#M137477</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-06T16:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510820#M137478</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;data have;
   informat input1 input2 binary6. ;
   input input1 input2;
   output = band(input1,input2);
   format output binary6.;
datalines;
111111 100   
111111 1001  
111111 101111
111111 111111
111110 100000
;&lt;/PRE&gt;
&lt;P&gt;When you use a an INPUT with 6. format you told it not to treat values as binary any more.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 16:56:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510820#M137478</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-06T16:56:35Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510822#M137479</link>
      <description>I do no processing on it. It is read in directly from a data base.&lt;BR /&gt;I saw your post before, however, it didn't work with these inputs.</description>
      <pubDate>Tue, 06 Nov 2018 16:59:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510822#M137479</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2018-11-06T16:59:07Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510824#M137480</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154084"&gt;@capam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I do no processing on it. It is read in directly from a data base.&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Sure, you read the data with SAS. But there are different ways to read data and many mistakes that one can make.&lt;/P&gt;
&lt;P&gt;Please show your code.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 17:03:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510824#M137480</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-06T17:03:30Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510835#M137481</link>
      <description>I get an error ERROR: No DATALINES or INFILE statement.&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Nov 2018 17:30:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510835#M137481</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2018-11-06T17:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510837#M137482</link>
      <description>&lt;P&gt;proc sql;&lt;BR /&gt;create table WS_data as&lt;BR /&gt;SELECT&lt;BR /&gt;FLT.*,&lt;BR /&gt;CCA.*,&lt;BR /&gt;CCA2.*&lt;/P&gt;&lt;P&gt;FROM RMDEOAP.GETS_DW_EOA_FAULTS FLT&lt;BR /&gt;full join RMDEOAP.GETS_DW_EOA_MP_AC_CCA CCA on (FLT.fault_objid=CCA.PARM2FAULT)&lt;BR /&gt;full join RMDEOAP.GETS_DW_EOA_MP_AC_CCA2 CCA2 on (FLT.fault_objid=CCA2.PARM2FAULT)&lt;BR /&gt;WHERE&lt;BR /&gt;FLT.vehicle_header='CN'&lt;BR /&gt;and Wheel_Diameter_1 is not null&lt;BR /&gt;and FLT.FAULT_CODE = '20-0001'&lt;/P&gt;&lt;P&gt;and FLT.occur_date between '01JAN2015:00:00:00'dt and datetime()&lt;BR /&gt;order by Unit&lt;BR /&gt;;&lt;BR /&gt;quit;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 17:33:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510837#M137482</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2018-11-06T17:33:43Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510845#M137483</link>
      <description>&lt;P&gt;Thanks for posting the code. So, most likely your &lt;FONT face="courier new,courier"&gt;input1&lt;/FONT&gt;, &lt;FONT face="courier new,courier"&gt;input2&lt;/FONT&gt; variables contain either character values like '101101' (which are automatically converted to numeric values when you apply the BAND function to them) or decimal numeric values like 101101. For a solution it's important to know: Are they &lt;EM&gt;numeric&lt;/EM&gt; or &lt;EM&gt;character&lt;/EM&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit: The solutions for the two cases differ in the arguments of the BAND function:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Case 1: &lt;EM&gt;character&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;band(input(left(input1),binary.),input(left(input2),binary.))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;EM&gt;&lt;/EM&gt;The LEFT function can be omitted if the values are already left-aligned or if they have a length &amp;lt;=8.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Case 2: &lt;EM&gt;numeric&lt;/EM&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;band(input(put(input1,6.),binary.),input(put(input2,6.),binary.))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 18:45:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510845#M137483</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-06T18:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510849#M137484</link>
      <description>numeric</description>
      <pubDate>Tue, 06 Nov 2018 18:37:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510849#M137484</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2018-11-06T18:37:22Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510852#M137485</link>
      <description>It may be important to note that the 1st 3 output digits are correct counting from right to left. The last 3 digits are left out.</description>
      <pubDate>Tue, 06 Nov 2018 18:43:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510852#M137485</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2018-11-06T18:43:50Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510854#M137486</link>
      <description>&lt;P&gt;Thanks. So, this example should match your situation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input input1 input2;
cards;
111111 100
111111 1001
111111 101111
111111 111111
111110 100000
;

/* Binary output */

data want;
set have;
output = band(input(put(input1,6.),binary.),input(put(input2,6.),binary.));
format output binary6.;
run;

/* Decimal output (not suitable for use as binary values!) */

data want;
set have;
output = input(put(band(input(put(input1,6.),binary.),input(put(input2,6.),binary.)),binary6.),6.);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Nov 2018 18:50:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510854#M137486</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-06T18:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510859#M137487</link>
      <description>Case 2 produces correct output when followed by a format:&lt;BR /&gt;format output binary6.;&lt;BR /&gt;How do I remove the extra zeros on the left. Thanks so much.&lt;BR /&gt;</description>
      <pubDate>Tue, 06 Nov 2018 19:09:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510859#M137487</guid>
      <dc:creator>capam</dc:creator>
      <dc:date>2018-11-06T19:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510865#M137488</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154084"&gt;@capam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I get an error ERROR: No DATALINES or INFILE statement.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Show your code and error messages from the Log. Paste into a code box opened with the {I] icon here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bet you missed a ; somewhere.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 19:25:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510865#M137488</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-06T19:25:04Z</dc:date>
    </item>
    <item>
      <title>Re: binary and usage</title>
      <link>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510866#M137489</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/154084"&gt;@capam&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Case 2 produces correct output when followed by a format:&lt;BR /&gt;format output binary6.;&lt;BR /&gt;How do I remove the extra zeros on the left. Thanks so much.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I think you refer to my earlier post where I outlined the two cases. The "decimal output" solution in the more recent post removes the leading zeros by converting the binary numbers to decimal numbers, e.g., the binary 4 (100 in the binary system) is converted to the decimal 100 (one hundred). Alternatively, you could define &lt;FONT face="courier new,courier"&gt;output&lt;/FONT&gt; as a character variable if it's only used for reporting purposes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Character output */

data want;
set have;
output = put(input(put(band(input(put(input1,6.),binary.),input(put(input2,6.),binary.)),binary6.),6.),6.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Nov 2018 19:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/binary-and-usage/m-p/510866#M137489</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2018-11-06T19:31:41Z</dc:date>
    </item>
  </channel>
</rss>

