<?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: Trying to build multiple if conditions with macro variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-build-multiple-if-conditions-with-macro-variables/m-p/890706#M351946</link>
    <description>It works, Thank you so much!</description>
    <pubDate>Thu, 24 Aug 2023 08:43:01 GMT</pubDate>
    <dc:creator>JenniferLee</dc:creator>
    <dc:date>2023-08-24T08:43:01Z</dc:date>
    <item>
      <title>Trying to build multiple if conditions with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-build-multiple-if-conditions-with-macro-variables/m-p/890697#M351940</link>
      <description>&lt;P&gt;Here is the code I'm trying to execute but keep hitting error.&lt;/P&gt;
&lt;P&gt;&amp;amp;FLG is a variable imported from a different table&lt;/P&gt;
&lt;P&gt;&amp;amp;macro1 and &amp;amp;macro2 are variables I'm trying to store values based on the condition rules (condition1-4).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;The original code with success&amp;gt;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set table;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; where condition;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if condition1 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;amp;macro1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; else do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;amp;macro2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;lt;The edited code with failure&amp;gt;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; set table;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; where condition;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; if &amp;amp;FLG. eq Y then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if condition1 then &amp;amp;macro1.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if condition2 then &amp;amp;macro2.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; if &amp;amp;FLG. eq N then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;if condition3 then &amp;amp;macro1.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if condition4 then &amp;amp;macro2.;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It would be a great help if you can advise which part I'm missing and how to fix the code to run successfully.&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 07:47:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-build-multiple-if-conditions-with-macro-variables/m-p/890697#M351940</guid>
      <dc:creator>JenniferLee</dc:creator>
      <dc:date>2023-08-24T07:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to build multiple if conditions with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-build-multiple-if-conditions-with-macro-variables/m-p/890698#M351941</link>
      <description>&lt;P&gt;In data step code, you compare variables or values. Character values have to be enclosed in quotes. So, when your %flg macro returns either a Y or N, the data step code has to be&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; if "%FLG" eq "Y" then do;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Aug 2023 07:08:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-build-multiple-if-conditions-with-macro-variables/m-p/890698#M351941</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-08-24T07:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Trying to build multiple if conditions with macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Trying-to-build-multiple-if-conditions-with-macro-variables/m-p/890706#M351946</link>
      <description>It works, Thank you so much!</description>
      <pubDate>Thu, 24 Aug 2023 08:43:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Trying-to-build-multiple-if-conditions-with-macro-variables/m-p/890706#M351946</guid>
      <dc:creator>JenniferLee</dc:creator>
      <dc:date>2023-08-24T08:43:01Z</dc:date>
    </item>
  </channel>
</rss>

