<?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: Problems STored Proces macro parameters in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problems-STored-Proces-macro-parameters/m-p/279761#M19282</link>
    <description>&lt;P&gt;There are at least two issues in what you posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like&amp;nbsp; you are trying to see if a macro variable has a null value by using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %nrquote(&amp;amp;banavn) eq ' '&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's the wrong way to do it.&amp;nbsp; While there are many working ways, this is my preference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %length(&amp;amp;banavn) eq 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code that you have now is actually checking whether the macro variable is three characters long, with the first and third characters equal to a single quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the RUN statement is in the wrong place.&amp;nbsp; Right now, it follows the definition of the macro.&amp;nbsp; It has to be moved later, following the invocation of the macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%udtrak&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RUN statement actually could become part of the macro definition instead.&amp;nbsp; (There are cases where the separate RUN statement gives the macro more flexibility, providing the ability to add more statements between the macro invocation and the RUN statement.&amp;nbsp; This particular DATA step has OUTPUT statements within the macro definition, so that added flexibility would not be useful.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may be more that I haven't seen, but cleaning up these two issues should be a good start.&lt;/P&gt;</description>
    <pubDate>Thu, 23 Jun 2016 15:58:05 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-06-23T15:58:05Z</dc:date>
    <item>
      <title>Problems STored Proces macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problems-STored-Proces-macro-parameters/m-p/279748#M19278</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got a stored process with a lot of macro parameters. But I can not get it to work properly. The parameters does not work in the selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you see what is wrong and why the paramters will not work???? it is especially the two date macro parameters: "&amp;amp;fradato."d and&lt;/P&gt;&lt;P&gt;"&amp;amp;tildato."d&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Some code from the stored process:&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%macro udtrak;&lt;/P&gt;&lt;P&gt;data idataperiode fordataperiode;&lt;BR /&gt;&lt;BR /&gt;set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%if %nrquote(&amp;amp;banavn) eq ' '&amp;nbsp; or %nrquote(&amp;amp;banavn) eq _ALL_VALUES_ %then %do;&lt;BR /&gt;&amp;nbsp;if transaction_date_d &amp;gt;="&amp;amp;fradato."d and&amp;nbsp; transaction_date_d &amp;lt;="&amp;amp;tildato."d and regime_number in("&amp;amp;ordning") then output idataperiode;&lt;BR /&gt;&amp;nbsp;if transaction_date_d &amp;lt; "&amp;amp;fradato."d and regime_number in("&amp;amp;ordning") then output fordataperiode;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;%if %nrquote(&amp;amp;fsnavn) eq ' ' or %nrquote(&amp;amp;fsnavn)eq _ALL_VALUES_%then %do;&lt;/P&gt;&lt;P&gt;if transaction_date_d &amp;gt;="&amp;amp;fradato."d and&amp;nbsp; transaction_date_d &amp;lt;="&amp;amp;tildato."d and regime_number in("&amp;amp;ordning") and ba_id in("&amp;amp;banavn")&lt;BR /&gt;&amp;nbsp;then output idataperiode;&lt;BR /&gt;if transaction_date_d &amp;lt;"&amp;amp;fradato."d and regime_number in("&amp;amp;ordning") and ba_id in("&amp;amp;banavn") then output fordataperiode;&lt;BR /&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;%if %nrquote(&amp;amp;fsnavn) ne ' ' and %nrquote(&amp;amp;banavn) ne ' ' %then %do;&lt;BR /&gt;if transaction_date_d &amp;gt;="&amp;amp;fradato."d and&amp;nbsp; transaction_date_d &amp;lt;="&amp;amp;tildato."d and regime_number in("&amp;amp;ordning")&lt;BR /&gt;and ba_id in("&amp;amp;banavn") and focusarea_id in("&amp;amp;fsnavn") then output idataperiode;&lt;/P&gt;&lt;P&gt;if transaction_date_d &amp;lt;"&amp;amp;fradato."d&amp;nbsp; and regime_number in("&amp;amp;ordning") and&lt;BR /&gt;ba_id in("&amp;amp;banavn") and focusarea_id in("&amp;amp;fsnavn")&amp;nbsp;&amp;nbsp; then output fordataperiode;&lt;BR /&gt;%end;&lt;BR /&gt;%mend udtrak;&lt;BR /&gt;run;&lt;BR /&gt;%udtrak;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 14:41:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problems-STored-Proces-macro-parameters/m-p/279748#M19278</guid>
      <dc:creator>ANLYNG</dc:creator>
      <dc:date>2016-06-23T14:41:22Z</dc:date>
    </item>
    <item>
      <title>Re: Problems STored Proces macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problems-STored-Proces-macro-parameters/m-p/279761#M19282</link>
      <description>&lt;P&gt;There are at least two issues in what you posted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like&amp;nbsp; you are trying to see if a macro variable has a null value by using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %nrquote(&amp;amp;banavn) eq ' '&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That's the wrong way to do it.&amp;nbsp; While there are many working ways, this is my preference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%if %length(&amp;amp;banavn) eq 0&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code that you have now is actually checking whether the macro variable is three characters long, with the first and third characters equal to a single quote.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the RUN statement is in the wrong place.&amp;nbsp; Right now, it follows the definition of the macro.&amp;nbsp; It has to be moved later, following the invocation of the macro:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%udtrak&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The RUN statement actually could become part of the macro definition instead.&amp;nbsp; (There are cases where the separate RUN statement gives the macro more flexibility, providing the ability to add more statements between the macro invocation and the RUN statement.&amp;nbsp; This particular DATA step has OUTPUT statements within the macro definition, so that added flexibility would not be useful.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There may be more that I haven't seen, but cleaning up these two issues should be a good start.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jun 2016 15:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problems-STored-Proces-macro-parameters/m-p/279761#M19282</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-06-23T15:58:05Z</dc:date>
    </item>
    <item>
      <title>Re: Problems STored Proces macro parameters</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problems-STored-Proces-macro-parameters/m-p/280185#M19297</link>
      <description>&lt;P&gt;Thank you very much. It did help and it looks nice. I am very happy thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jun 2016 07:22:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Problems-STored-Proces-macro-parameters/m-p/280185#M19297</guid>
      <dc:creator>ANLYNG</dc:creator>
      <dc:date>2016-06-26T07:22:02Z</dc:date>
    </item>
  </channel>
</rss>

