<?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 If Statements useing a macro variable created in a Macro in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statements-useing-a-macro-variable-created-in-a-Macro/m-p/397142#M25545</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a problem in this code... the "IF" statement dont work... someone can help me?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Macro Variable G_STATUS&amp;nbsp;&amp;nbsp;is created in this Macro&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;%macro CONSULTAR_TABELA(RELATORIO,BASE);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%GLOBAL G_STATUS;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%LOCAL STATUS;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc sql;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SELECT T1.status INTO: STATUS&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM CONTROLE.BASE_VALIDADOR T1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WHERE COMPRESS(RELATORIO) EQ &amp;amp;RELATORIO. AND COMPRESS(TABELA) EQ &amp;amp;BASE.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;RUN;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%LET &lt;STRONG&gt;G_STATUS&lt;/STRONG&gt; = &amp;amp;STATUS;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%mend CONSULTAR_TABELA;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i would like to use this macro variable in this "IF" conditional:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data _NULL_;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%let RELATORIO = 'SOL';&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%let TABELA = 'ZCRM_O02';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%CONSULTAR_TABELA(&amp;amp;RELATORIO,&amp;amp;TABELA);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;%IF &amp;amp;g_status ="EM ATUALIZACAO" %then&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;x=1;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;61 %IF &amp;amp;g_status ="EM ATUALIZACAO" %then&lt;/EM&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;ERROR: The %IF statement is not valid in open code.&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;62 x=1;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;63 run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;thanks for all&lt;/EM&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 19 Sep 2017 14:56:45 GMT</pubDate>
    <dc:creator>carlosnreis</dc:creator>
    <dc:date>2017-09-19T14:56:45Z</dc:date>
    <item>
      <title>If Statements useing a macro variable created in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statements-useing-a-macro-variable-created-in-a-Macro/m-p/397142#M25545</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a problem in this code... the "IF" statement dont work... someone can help me?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Macro Variable G_STATUS&amp;nbsp;&amp;nbsp;is created in this Macro&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;EM&gt;%macro CONSULTAR_TABELA(RELATORIO,BASE);&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%GLOBAL G_STATUS;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%LOCAL STATUS;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;proc sql;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;SELECT T1.status INTO: STATUS&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;FROM CONTROLE.BASE_VALIDADOR T1&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;WHERE COMPRESS(RELATORIO) EQ &amp;amp;RELATORIO. AND COMPRESS(TABELA) EQ &amp;amp;BASE.&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;RUN;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%LET &lt;STRONG&gt;G_STATUS&lt;/STRONG&gt; = &amp;amp;STATUS;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%mend CONSULTAR_TABELA;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and i would like to use this macro variable in this "IF" conditional:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;data _NULL_;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%let RELATORIO = 'SOL';&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%let TABELA = 'ZCRM_O02';&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;%CONSULTAR_TABELA(&amp;amp;RELATORIO,&amp;amp;TABELA);&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;%IF &amp;amp;g_status ="EM ATUALIZACAO" %then&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;x=1;&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;61 %IF &amp;amp;g_status ="EM ATUALIZACAO" %then&lt;/EM&gt;&lt;BR /&gt;&lt;STRONG&gt;&lt;EM&gt;ERROR: The %IF statement is not valid in open code.&lt;/EM&gt;&lt;/STRONG&gt;&lt;BR /&gt;&lt;EM&gt;62 x=1;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;63 run;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;thanks for all&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 14:56:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statements-useing-a-macro-variable-created-in-a-Macro/m-p/397142#M25545</guid>
      <dc:creator>carlosnreis</dc:creator>
      <dc:date>2017-09-19T14:56:45Z</dc:date>
    </item>
    <item>
      <title>Re: If Statements useing a macro variable created in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statements-useing-a-macro-variable-created-in-a-Macro/m-p/397146#M25547</link>
      <description>&lt;P&gt;Well, the error is correct, macro logic is only good within a macro.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you trying to do? Yes, your code doesn't work, but without knowing what you're tyring to accomplish we can't offer a solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 14:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statements-useing-a-macro-variable-created-in-a-Macro/m-p/397146#M25547</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-09-19T14:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: If Statements useing a macro variable created in a Macro</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statements-useing-a-macro-variable-created-in-a-Macro/m-p/397156#M25551</link>
      <description>&lt;P&gt;A couple of things to fix ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, your macro runs PROC SQL.&amp;nbsp; You don't do that in the middle of a DATA step.&amp;nbsp; So switch the order:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;%let RELATORIO = 'SOL';&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;%let TABELA = 'ZCRM_O02';&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;%CONSULTAR_TABELA(&amp;amp;RELATORIO,&amp;amp;TABELA);&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;data _null_;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next, even though %IF / %THEN is illegal,&amp;nbsp; you don't really need it.&amp;nbsp; You have started a DATA step, which uses IF / THEN (not %IF / %THEN).&amp;nbsp; So you could use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data _null_;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;IF "&amp;amp;g_status" ="EM ATUALIZACAO" then &lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;&lt;EM&gt;x=1;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you merely want to examine the value of &amp;amp;G_STATUS instead of running a DATA step, you could simply use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%put &amp;amp;G_STATUS;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Sep 2017 15:13:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/If-Statements-useing-a-macro-variable-created-in-a-Macro/m-p/397156#M25551</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-09-19T15:13:45Z</dc:date>
    </item>
  </channel>
</rss>

