<?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: Bit Testing inside macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592098#M169735</link>
    <description>&lt;P&gt;Then you can use macro to generate DATA step IF statements. Regarding PROC COMPARE I've found this logic helpful. I don't think you have to test for every possible bit code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let base = MyBaseData;
%let compare = MyCompareData;

proc compare base = &amp;amp;base
             comp = &amp;amp;compare
             listvar out = difs outnoequal
            ;
  ID MyIDVar;
run;

%let rc = &amp;amp;sysinfo;

data _null_;
 %* Test for data set label ;
   if &amp;amp;rc = '1'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Data sets have different labels";
 %* Test for data set types ;
   if &amp;amp;rc = '1.'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Data set types differ";
 %* Test for label ;
   if &amp;amp;rc = '1.....'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Variable has different label";
 %* Test for base observation ;
   if &amp;amp;rc = '1......'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Base data set has observation not in comparison data set";
 %* Test for length ;
   if &amp;amp;rc = '1....'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Variable has different lengths between the base data set and the comparison data set";
 %* Variable in base data set not in compare data set;
   if &amp;amp;rc ='1..........'b then 
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Variable in base data set not found in comparison data set";
 %* Comparison data set has variable not in base data set ;
   if &amp;amp;rc = '1...........'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Comparison data set has variable not contained in the base data set";
 %* Test for values ;
   if &amp;amp;rc = '1............'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: A value comparison was unequal";
 %* Conflicting variable types;
   if &amp;amp;rc ='1.............'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Conflicting variable types between the two data sets being compared";
run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 27 Sep 2019 06:52:12 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2019-09-27T06:52:12Z</dc:date>
    <item>
      <title>Bit Testing inside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592090#M169731</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to do bit testing. It works when I write it as a data step but fails if i wrap it inside a macro. What am i missing here ? Below is the simple code. The one in bold works but the one in red doesn't.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#993300"&gt;options symbolgen mlogic mprint;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;%macro test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;%let a = 4096;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;%let b= '1............'b;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;data a;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;%if &amp;amp;a =&amp;amp;b %then %do;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;x=10;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;%end;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;run;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;%mend;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;%test;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;proc print data=a;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#993300"&gt;run;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;%let a = 4096;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;%let b= '1............'b;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;data a;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if &amp;amp;a =&amp;amp;b then do;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;x=10;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;proc print data=a;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 05:56:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592090#M169731</guid>
      <dc:creator>avinashjha1787</dc:creator>
      <dc:date>2019-09-27T05:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Bit Testing inside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592091#M169732</link>
      <description>&lt;P&gt;Macro IF statements (%IF) can't do bit-type comparisons, only text ones. Why do you want to do it in a macro statement?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 06:11:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592091#M169732</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-09-27T06:11:31Z</dc:date>
    </item>
    <item>
      <title>Re: Bit Testing inside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592094#M169733</link>
      <description>&lt;P&gt;I am using it to compare sysinfo value set by Proc Compare. The macro takes two datasets, does Proc Compare and then a loop executes 16 times to compare sysinfo value with the bit value and if matched, save the error description. There are over 3000 datasets to be compared so i was using a macro.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Sep 2019 06:24:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592094#M169733</guid>
      <dc:creator>avinashjha1787</dc:creator>
      <dc:date>2019-09-27T06:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Bit Testing inside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592098#M169735</link>
      <description>&lt;P&gt;Then you can use macro to generate DATA step IF statements. Regarding PROC COMPARE I've found this logic helpful. I don't think you have to test for every possible bit code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let base = MyBaseData;
%let compare = MyCompareData;

proc compare base = &amp;amp;base
             comp = &amp;amp;compare
             listvar out = difs outnoequal
            ;
  ID MyIDVar;
run;

%let rc = &amp;amp;sysinfo;

data _null_;
 %* Test for data set label ;
   if &amp;amp;rc = '1'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Data sets have different labels";
 %* Test for data set types ;
   if &amp;amp;rc = '1.'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Data set types differ";
 %* Test for label ;
   if &amp;amp;rc = '1.....'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Variable has different label";
 %* Test for base observation ;
   if &amp;amp;rc = '1......'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Base data set has observation not in comparison data set";
 %* Test for length ;
   if &amp;amp;rc = '1....'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Variable has different lengths between the base data set and the comparison data set";
 %* Variable in base data set not in compare data set;
   if &amp;amp;rc ='1..........'b then 
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Variable in base data set not found in comparison data set";
 %* Comparison data set has variable not in base data set ;
   if &amp;amp;rc = '1...........'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Comparison data set has variable not contained in the base data set";
 %* Test for values ;
   if &amp;amp;rc = '1............'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: A value comparison was unequal";
 %* Conflicting variable types;
   if &amp;amp;rc ='1.............'b then
      put "&amp;lt;&amp;lt;&amp;lt;&amp;lt; &amp;amp;compare.: Conflicting variable types between the two data sets being compared";
run;
 &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Sep 2019 06:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592098#M169735</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-09-27T06:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Bit Testing inside macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592103#M169736</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can use the band function as follows :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let VALUE_COMPARISON_UNEQUAL=4096;

%macro compare(ds1,ds2);
    
    proc compare base=&amp;amp;ds1. comp=&amp;amp;ds2. noprint;
    run;

    %if %sysfunc(band(&amp;amp;sysinfo., &amp;amp;VALUE_COMPARISON_UNEQUAL.)) %then %put Different values found;

%mend;

data a;
x=1;
run;

data b;
x=1;
y=2;
run;

data c;
x=2;
run;

%compare(a,b);
%compare(a,c);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Sep 2019 08:25:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Bit-Testing-inside-macro/m-p/592103#M169736</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2019-09-27T08:25:25Z</dc:date>
    </item>
  </channel>
</rss>

