<?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 check if a macro variable has a specified value in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-macro-variable-has-a-specified-value/m-p/975801#M378177</link>
    <description>&lt;P&gt;To see why you got that message turn the MPRINT option before running the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should see that you generated lines like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF est = "est" THEN flg_est = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which to the data step compiler means you want to compare the value of the variable named EST to the string literal "est".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just add quotes around the value in your macro code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF "&amp;amp;sheet." = "est" THEN flg_est = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So that it generates this SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF "est" = "est" THEN flg_est = 1&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 26 Sep 2025 15:31:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-09-26T15:31:11Z</dc:date>
    <item>
      <title>How to check if a macro variable has a specified value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-macro-variable-has-a-specified-value/m-p/975800#M378176</link>
      <description>&lt;P&gt;I'm importing several Excel files. Each has 3 sheets: Known from Source 1 (known1), Known from Source 2 (known2), and Estimated (est). After importation, all 3 sheets will be merged into a single SAS file. I need to flag the imported records to show if they came from the Estimated sheet or not.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think I need a conditional IF statement, but I can't get the code right. The code I have now basically says that if the variable est equals the value "est" then... But of course there is no variable named est, so it doesn't work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro import(sheet);

DATA want; SET have;
IF &amp;amp;sheet. = "est" THEN flg_est = 1; ELSE flg_est= 0;
RUN;

%mend;
%import(known1)
%import(known2)
%import(est)

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Sep 2025 15:13:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-macro-variable-has-a-specified-value/m-p/975800#M378176</guid>
      <dc:creator>Wolverine</dc:creator>
      <dc:date>2025-09-26T15:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to check if a macro variable has a specified value</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-macro-variable-has-a-specified-value/m-p/975801#M378177</link>
      <description>&lt;P&gt;To see why you got that message turn the MPRINT option before running the macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You should see that you generated lines like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF est = "est" THEN flg_est = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which to the data step compiler means you want to compare the value of the variable named EST to the string literal "est".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just add quotes around the value in your macro code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF "&amp;amp;sheet." = "est" THEN flg_est = 1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So that it generates this SAS code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF "est" = "est" THEN flg_est = 1&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 26 Sep 2025 15:31:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-check-if-a-macro-variable-has-a-specified-value/m-p/975801#M378177</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-26T15:31:11Z</dc:date>
    </item>
  </channel>
</rss>

