<?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: Macro Error in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239784#M44164</link>
    <description>&lt;P&gt;Hi, I don't have an anwer, but some thoughts.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;If the exact macro works to pull data from Teradata, but not Oracle, you should look a the parts of the macro that deped on the source (e.g. the connection string), to see what differs.&lt;/LI&gt;&lt;LI&gt;When you say you're getting a syntax error, what error do you get, and when do you get it?&amp;nbsp; For example, do you get it when the macro compiles, or when it executes?&amp;nbsp; Does it look like an eror message from SAS or from Oracle?&lt;/LI&gt;&lt;LI&gt;As written it's a lot of code for people to review.&amp;nbsp; It's a good candidate for a bit of brute force debugging on your end. If you cut the query in half, do you get an error?&amp;nbsp; Then repeat cutting in half until you get to the point where error magically goes away, or you have a simple query (PROC SQL step with 5-10 lines) which still shows an error, and post that.&lt;/LI&gt;&lt;LI&gt;Also curious what &amp;amp;TBL_B_DIAG_SEXW5A_CDWX resolves to, any other global macro vars referenced like &amp;amp;BEGDATE and &amp;amp;ENDDATE.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps a start.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2015 16:50:55 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2015-12-17T16:50:55Z</dc:date>
    <item>
      <title>Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239771#M44162</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm not sure why I get a syntax error. &amp;nbsp;It says I'm missing an extra paren. &amp;nbsp;This is extracting data from an Oracle database, however, this same exact macro works in teradata. &amp;nbsp; This is the macro code, I'm using the %bquoute to help avoid an error about more positional parameters than defined.&lt;/P&gt;
&lt;P&gt;%macro looper(_tblname, _varnme); &lt;BR /&gt; *-----------------------------------------------------*&lt;BR /&gt; IDENTIFY CLAIMS/ENCOUNTERS (XCELYS PROFESSIONAL) BY&lt;BR /&gt; ICD9 DIAGNOSIS CODES &lt;BR /&gt; *-----------------------------------------------------*;&lt;BR /&gt;Proc SQL;&lt;BR /&gt; /*CONNECT to ORACLE (path= 'ISARNP.world' );*/&lt;BR /&gt; Create Table &amp;amp;_tblname as&lt;BR /&gt; /* VARIABLE NAMES USED IN HEDIS PROGRAMMING: */&lt;BR /&gt; (Select Distinct /* ----------------------------------------- */&lt;BR /&gt; A.clm_nb /* CLM_NBR */&lt;BR /&gt; ,A.clm_sts_cd&lt;BR /&gt; ,A.src_sys_cd&lt;BR /&gt; ,A.frst_svc_dt /* SVC_B_DT */ &lt;BR /&gt; ,A.prmy_diag_cd &lt;BR /&gt; ,D.indvd_id_nb /* INDV_HRN */ &lt;BR /&gt; ,E.plc_of_svc_cd /* POS_CD */&lt;BR /&gt; ,B.diag_lne_nb&lt;BR /&gt; ,B.icd_diag_cd /* DIAG_CD */&lt;BR /&gt; From &lt;BR /&gt; CDW.PROF_CLM_HDR A&lt;BR /&gt; /*INNER JOIN &lt;BR /&gt; CDW.prof_CLM_HDR_PRVDR F &lt;BR /&gt; on A.prof_clm_ik = F.prof_clm_ik&lt;BR /&gt; and A.rgn_cd = F.rgn_cd &lt;BR /&gt; and A.src_sys_cd = F.src_sys_cd*/&lt;BR /&gt; INNER JOIN &lt;BR /&gt; CDW.PROF_CLM_DTL C &lt;BR /&gt; on A.prof_clm_ik = C.prof_clm_ik&lt;BR /&gt; and A.rgn_cd = C.rgn_cd &lt;BR /&gt; and A.src_sys_cd = C.src_sys_cd&lt;BR /&gt; INNER JOIN &lt;BR /&gt; CDW.PROF_CLM_INDVD D &lt;BR /&gt; on A.prof_clm_ik = D.prof_clm_ik&lt;BR /&gt; and A.rgn_cd = D.rgn_cd &lt;BR /&gt; and A.src_sys_cd = D.src_sys_cd&lt;BR /&gt; INNER JOIN &lt;BR /&gt; CDW.PROF_CLM_PLC_OF_SVC E &lt;BR /&gt; on A.prof_clm_ik = E.prof_clm_ik&lt;BR /&gt; and A.rgn_cd = E.rgn_cd &lt;BR /&gt; and A.src_sys_cd = E.src_sys_cd&lt;BR /&gt; INNER JOIN &lt;BR /&gt; CDW.PROF_CLM_HDR_DIAG B &lt;BR /&gt; on A.prof_clm_ik = B.prof_clm_ik&lt;BR /&gt; and A.rgn_cd = B.rgn_cd &lt;BR /&gt; and A.src_sys_cd = B.src_sys_cd&lt;BR /&gt; Where&lt;BR /&gt; A.src_sys_cd = 'Xcelys ROC'&lt;BR /&gt; and A.rgn_cd ='CO'&lt;BR /&gt; and A.frst_svc_dt Between &amp;amp;BEGDATE AND &amp;amp;ENDDATE&lt;BR /&gt; and A.most_rcnt_clm_ver_in_cd='Y'&lt;BR /&gt; and D.indvd_role_cd = 'Patient'&lt;BR /&gt; /*and F.prvdr_role_cd = 'Rendering - Billing'*/&lt;BR /&gt; and A.intrl_extl_cd = 'External'&lt;BR /&gt; /*-- TO FILTER BY DIAGNOSIS --*/&lt;BR /&gt; and B.clsfn_schm_cd in ('ICD-9','ICD-10')&lt;BR /&gt; and B.icd_diag_cd in %str(&amp;amp;&amp;amp;_varnme.)&lt;BR /&gt;);&lt;BR /&gt;Quit;&lt;/P&gt;
&lt;P&gt;%mend;&lt;BR /&gt;%looper(CHL_PROF_DIAG1, %bquote(&amp;amp;TBL_B_DIAG_SEXW5A_CDWX.));&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 16:11:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239771#M44162</guid>
      <dc:creator>suncawy</dc:creator>
      <dc:date>2015-12-17T16:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239784#M44164</link>
      <description>&lt;P&gt;Hi, I don't have an anwer, but some thoughts.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;If the exact macro works to pull data from Teradata, but not Oracle, you should look a the parts of the macro that deped on the source (e.g. the connection string), to see what differs.&lt;/LI&gt;&lt;LI&gt;When you say you're getting a syntax error, what error do you get, and when do you get it?&amp;nbsp; For example, do you get it when the macro compiles, or when it executes?&amp;nbsp; Does it look like an eror message from SAS or from Oracle?&lt;/LI&gt;&lt;LI&gt;As written it's a lot of code for people to review.&amp;nbsp; It's a good candidate for a bit of brute force debugging on your end. If you cut the query in half, do you get an error?&amp;nbsp; Then repeat cutting in half until you get to the point where error magically goes away, or you have a simple query (PROC SQL step with 5-10 lines) which still shows an error, and post that.&lt;/LI&gt;&lt;LI&gt;Also curious what &amp;amp;TBL_B_DIAG_SEXW5A_CDWX resolves to, any other global macro vars referenced like &amp;amp;BEGDATE and &amp;amp;ENDDATE.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that helps a start.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 16:50:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239784#M44164</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2015-12-17T16:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239793#M44165</link>
      <description>&lt;P&gt;I think you overdid the macro quoting. Using %BQUOTE, %STR and a double ampersand together looks suspicious to me. Indeed, it would be interesting what type of contents&amp;nbsp;&lt;SPAN&gt;&amp;amp;TBL_B_DIAG_SEXW5A_CDWX. resolves to.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt; Please note that the IN operator in the line&amp;nbsp;&lt;FONT face="courier new,courier"&gt;and B.icd_diag_cd in %str(&amp;amp;&amp;amp;_varnme.)&lt;/FONT&gt;&amp;nbsp;at the end of your macro requires a list in parentheses. Probably, these parentheses are &lt;EM&gt;not&lt;/EM&gt;&amp;nbsp;contained in&amp;nbsp;&amp;amp;TBL_B_DIAG_SEXW5A_CDWX. (I guess that's why you use %BQUOTE). But %STR(&amp;amp;&amp;amp;_varnme.) won't create them either. So, it is not surprising that you may be "missing an extra paren." (in fact two of them).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;On the other hand, if you could include the parentheses into&amp;nbsp;&amp;amp;TBL_B_DIAG_SEXW5A_CDWX., so that this macro variable resolves to, say,&amp;nbsp;&lt;FONT face="courier new,courier"&gt;('R94.120', 'H61.113')&lt;/FONT&gt;, i.e., a list of ICD codes in parentheses, I think you could simply say (in the abovementioned line of code)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;and B.icd_diag_cd in &amp;amp;_varnme.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;SPAN&gt;and call the macro as simply as&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;%looper(CHL_PROF_DIAG1, &amp;amp;TBL_B_DIAG_SEXW5A_CDWX.);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 17:24:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239793#M44165</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-12-17T17:24:14Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239799#M44167</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for the help. &amp;nbsp;The&amp;nbsp;&lt;SPAN&gt;&amp;amp;TBL_B_DIAG_SEXW5A_CDWX does resolve to a list of codes because of restrictions, I can only have a list of 1,000 codes to pass to a macro variable, so there is a macro ..SEXW5B, SEXW5C, etc. and each macro variable contains less than the 1,000 of those. &amp;nbsp;This is an example of the issue:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;NOTE: Line generated by the macro variable "_VARNME".&lt;BR /&gt;1 '630','631.0','631.8','632','633.00','633.01','633.10','633.11','633.20','633.21','633.80','633.81','633.90','633.91','634.00'&lt;BR /&gt; -&lt;BR /&gt; 22&lt;BR /&gt; -&lt;BR /&gt; 76&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant, a datetime constant,&lt;BR /&gt; a missing value, (, -, SELECT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"at the end of your macro requires a list in parentheses. Probably, these parentheses are &lt;EM style="line-height: 1.2;"&gt;not&lt;/EM&gt;&amp;nbsp;contained in&amp;nbsp;&amp;amp;TBL_B_DIAG_SEXW5A_CDWX. (I guess that's why you use %BQUOTE). But %STR(&amp;amp;&amp;amp;_varnme.) won't create them either." &amp;nbsp; Yes, you are absolutely correct about this, so the problem is I'm not sure how else to include the parentheses in the macro variable.&lt;/P&gt;
&lt;P&gt;If I don't do %BQUOTE, then the error becomes "more positional parameters than defined".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 17:50:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239799#M44167</guid>
      <dc:creator>suncawy</dc:creator>
      <dc:date>2015-12-17T17:50:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239803#M44168</link>
      <description>&lt;P&gt;You could, for example, insert the parentheses in the macro call:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;%looper(CHL_PROF_DIAG1, &lt;STRONG&gt;(&lt;/STRONG&gt;&amp;amp;TBL_B_DIAG_SEXW5A_CDWX.&lt;STRONG&gt;)&lt;/STRONG&gt;);&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and still use the simple&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;SPAN&gt;and B.icd_diag_cd in &amp;amp;_varnme.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 17:57:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239803#M44168</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2015-12-17T17:57:35Z</dc:date>
    </item>
    <item>
      <title>Re: Macro Error</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239806#M44169</link>
      <description>&lt;P&gt;Perfect ! it worked..Thank you very much. &amp;nbsp; For me lesson learned, &amp;nbsp;make it less complex and keep it simple.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2015 18:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-Error/m-p/239806#M44169</guid>
      <dc:creator>suncawy</dc:creator>
      <dc:date>2015-12-17T18:15:48Z</dc:date>
    </item>
  </channel>
</rss>

