<?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: How to compare two variables and stop program if not equals in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820592#M323910</link>
    <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;.&amp;nbsp;I've already did the variable initialization as you suggested and didn't work. However you point to where my problem is, the else sentence had an ";" at the end that was not necessary. I removed it and now it is evaluating correctly the if-then-else sentence.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jun 2022 20:40:36 GMT</pubDate>
    <dc:creator>Kal_ETL</dc:creator>
    <dc:date>2022-06-27T20:40:36Z</dc:date>
    <item>
      <title>How to compare two variables and stop program if not equals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820574#M323896</link>
      <description>&lt;P&gt;Hello Communitie,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to validate a group of variables from two rows in same dataset, and if any of them doesn't match then abort/stop sas program. I tried something like this but doesn't seems to evaluate correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kal_ETL_0-1656357619239.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72763iDC1C3791F38CD0D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kal_ETL_0-1656357619239.png" alt="Kal_ETL_0-1656357619239.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data nextvar_compare;&lt;BR /&gt;nextvar=_n_+1;&lt;BR /&gt;set reporte end=last;&lt;BR /&gt;if not last &lt;BR /&gt;then set reporte(keep=nvar num_character num_numeric rename=(nvar=next_nvar num_character=next_num_character num_numeric=next_num_numeric)) point=nextvar;&lt;BR /&gt;else call missing(next_nvar, next_num_character, next_num_numeric);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data _null_;&lt;/P&gt;
&lt;P&gt;set nextvar_compare;&lt;BR /&gt;if nvar=next_nvar and num_character=next_num_character and num_numeric=next_num_numeric then&lt;BR /&gt;call symput("ValidaDS",0);&lt;BR /&gt;else;&lt;BR /&gt;call symput("ValidaDS",1);&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In a sas macro I would like to take ValidaDS value, if 1, then stop/abort, but always have a 1 even when the variables to compare have the same values&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Kal_ETL_1-1656357757376.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72764i963CDB37A15EB3E7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Kal_ETL_1-1656357757376.png" alt="Kal_ETL_1-1656357757376.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can anyone advice or have a better way to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 19:22:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820574#M323896</guid>
      <dc:creator>Kal_ETL</dc:creator>
      <dc:date>2022-06-27T19:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two variables and stop program if not equals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820585#M323906</link>
      <description>&lt;P&gt;Not sure I follow what you are trying to test, but I suspect the issue is your ELSE statement.&lt;/P&gt;
&lt;P&gt;If you want to set a macro variable if some condition is EVER true then first set the macro variable to a default value and then&amp;nbsp; set it to the opposite value when the condition is met.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let valid=1;
data _null_;
   .....
   if (... some condition...) then call symputx('valid','0');
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can then use &amp;amp;VALID to control future steps.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 20:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820585#M323906</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-27T20:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two variables and stop program if not equals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820592#M323910</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;.&amp;nbsp;I've already did the variable initialization as you suggested and didn't work. However you point to where my problem is, the else sentence had an ";" at the end that was not necessary. I removed it and now it is evaluating correctly the if-then-else sentence.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 20:40:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820592#M323910</guid>
      <dc:creator>Kal_ETL</dc:creator>
      <dc:date>2022-06-27T20:40:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to compare two variables and stop program if not equals</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820602#M323913</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/7559"&gt;@Kal_ETL&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;.&amp;nbsp;I've already did the variable initialization as you suggested and didn't work. However you point to where my problem is, the else sentence had an ";" at the end that was not necessary. I removed it and now it is evaluating correctly the if-then-else sentence.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So now the macro variable will reflect the result of IF/THEN/ELSE test for only the LAST observation in the dataset.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jun 2022 21:02:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-compare-two-variables-and-stop-program-if-not-equals/m-p/820602#M323913</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-27T21:02:05Z</dc:date>
    </item>
  </channel>
</rss>

