<?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: Apparent Syntax Error in Macro Driven PROC SQL Statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204933#M38113</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suspect it's the quoting character introduced by %QSCAN.&amp;nbsp; SQL sometimes has trouble with parsing when the quoting characters are present.&amp;nbsp; Switch to %SCAN instead and see if that takes care of the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 12 Jun 2015 15:14:18 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2015-06-12T15:14:18Z</dc:date>
    <item>
      <title>Apparent Syntax Error in Macro Driven PROC SQL Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204927#M38107</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a very strange issue.&amp;nbsp; I am using %DO loops to generate nearly 800 variables in a SQL statement, but SAS is complaining of a syntax error.&amp;nbsp; The strange part is that when I copy and paste the code from the log that is generated as a result of the %DO loops, the code runs perfectly fine!&amp;nbsp; Here is the code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro one_year_ru(pref=pb,end_dt='13OCT2013',end=71,values=%str(30,90,180,270,365,545,730));&lt;/P&gt;&lt;P&gt;%let count = 7;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table &amp;amp;pref._sales_ru as&lt;/P&gt;&lt;P&gt;select party_id,&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do i = 1 %to &amp;amp;count;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %let value=%qscan(&amp;amp;values,&amp;amp;i,%str(,));&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_interactions else 0 end) as num_interactions_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_trans else 0 end) as num_trans_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_rtrns else 0 end) as num_rtns_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_store_trans else 0 end) as num_store_trans_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_store_rtrns else 0 end) as num_store_rtrns_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_dir_trans else 0 end) as num_dir_trans_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_dir_rtrns else 0 end) as num_dir_rtrns_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then items_purchased else 0 end) as items_purchased_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_store_items else 0 end) as num_store_items_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_dir_items else 0 end) as num_dir_items_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then net_sales else 0 end) as net_sales_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then net_store_sales else 0 end) as net_store_sales_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then net_dir_sales else 0 end) as net_dir_sales_&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; %do j=1 %to &amp;amp;end.;&lt;/P&gt;&lt;P&gt;&amp;nbsp; max(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then if&amp;amp;j. else 0 end) as if&amp;amp;j._&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; sum(case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then iq&amp;amp;j. else 0 end) as iq&amp;amp;j._&amp;amp;value ,&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; max(tran_date) as last_purch_date&lt;/P&gt;&lt;P&gt;from &amp;amp;pref..sales_oct14&lt;/P&gt;&lt;P&gt;where tran_date between &amp;amp;end_dt.d-730 and &amp;amp;end_dt.d&lt;/P&gt;&lt;P&gt;group by 1&lt;/P&gt;&lt;P&gt;order by 1;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After invoking the macro, with default or changed parameters, SAS gives this error in the log:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;num_interactions_30&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 76&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: ',', LEN, LENGTH.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I look at the SQL statement generated in the log, there is clearly a COMMA:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MPRINT(ONE_YEAR_RU):&amp;nbsp;&amp;nbsp; create table pb_sales_ru as select party_id, sum(case when tran_date between&lt;/P&gt;&lt;P&gt;'13OCT2013'd-30 and '13OCT2013'd then num_interactions else 0 end) as num_interactions_30 ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated!!&amp;nbsp; Thank you!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 13:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204927#M38107</guid>
      <dc:creator>D8tAm1n3r_BEN</dc:creator>
      <dc:date>2015-06-12T13:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Syntax Error in Macro Driven PROC SQL Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204928#M38108</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;(partial) log would be helpful.&lt;/P&gt;&lt;P&gt;And why are you creating 800 variables? How do yo intend to use them next?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:02:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204928#M38108</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2015-06-12T14:02:21Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Syntax Error in Macro Driven PROC SQL Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204929#M38109</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;These are windowed variables to be passed into a feature selection algorithm for creating a logistic model.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do you want more of a partial log than what is at the bottom of the post, or of a different part of the log?&amp;nbsp; If so, here is some of it:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;MPRINT(ONE_YEAR_RU):&amp;nbsp;&amp;nbsp; proc sql;&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;NOTE: Line generated by the macro variable "VALUE".&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num_interactions_30&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 22&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; --&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 76&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;MPRINT(ONE_YEAR_RU):&amp;nbsp;&amp;nbsp; create table pb_sales_ru as select party_id, sum(case when tran_date between&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;'13OCT2013'd-30 and '13OCT2013'd then num_interactions else 0 end) as num_interactions_30 , sum(case&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;when tran_date between '13OCT2013'd-30 and '13OCT2013'd then num_trans else 0 end) as num_trans_30 ,&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then num_rtrns else 0 end) as&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;num_rtns_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then num_store_trans&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;else 0 end) as num_store_trans_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;then num_store_rtrns else 0 end) as num_store_rtrns_30 , sum(case when tran_date between&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;'13OCT2013'd-30 and '13OCT2013'd then num_dir_trans else 0 end) as num_dir_trans_30 , sum(case when&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;tran_date between '13OCT2013'd-30 and '13OCT2013'd then num_dir_rtrns else 0 end) as num_dir_rtrns_30&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;, sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then items_purchased else 0 end)&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;as items_purchased_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;num_store_items else 0 end) as num_store_items_30 , sum(case when tran_date between '13OCT2013'd-30&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;and '13OCT2013'd then num_dir_items else 0 end) as num_dir_items_30 , sum(case when tran_date between&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;'13OCT2013'd-30 and '13OCT2013'd then net_sales else 0 end) as net_sales_30 , sum(case when tran_date&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;between '13OCT2013'd-30 and '13OCT2013'd then net_store_sales else 0 end) as net_store_sales_30 ,&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then net_dir_sales else 0 end) as&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;net_dir_sales_30 , max(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then if1 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as if1_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then iq1 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as iq1_30 , max(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then if2 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as if2_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then iq2 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as iq2_30 , max(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then if3 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as if3_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then iq3 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as iq3_30 , max(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then if4 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as if4_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then iq4 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as iq4_30 , max(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then if5 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as if5_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then iq5 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as iq5_30 , max(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then if6 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;end) as if6_30 , sum(case when tran_date between '13OCT2013'd-30 and '13OCT2013'd then iq6 else 0&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;EM&gt;{TONS MORE LOG...}&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;EM&gt;&lt;STRONG&gt;ERROR 22-322: Syntax error, expecting one of the following: ',', LEN, LENGTH.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;EM&gt;&lt;STRONG&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:08:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204929#M38109</guid>
      <dc:creator>D8tAm1n3r_BEN</dc:creator>
      <dc:date>2015-06-12T14:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Syntax Error in Macro Driven PROC SQL Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204930#M38110</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, is 800 variables the best way to proceed?&amp;nbsp; How are you going to control such a vast amount of variables.&amp;nbsp; A brief look at your code, assign a code value to each row, depending on whether the date is between the required e.g.:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;case when tran_date between &amp;amp;end_dt.d-&amp;amp;value. and &amp;amp;end_dt.d then num_interactions else 0 end)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; background-color: #ffffff;"&gt;You then have a categorised dataset, which you can simply have one sum() and use a group by on the groups you have just created.&amp;nbsp; Personally I would look again at what you want to acheive as there is likely to be better methods.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204930#M38110</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-06-12T14:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Syntax Error in Macro Driven PROC SQL Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204931#M38111</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I appreciate the input--this is a multi-hundred gigabyte permanent dataset and each operation on it takes roughly an hour or more--a single PROC SQL with windowed variables has proven, over our work with our nearly 20 TB of data, to be the most efficient approach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We have models that we build which will have starting variable cardinality in the thousands, so the number of variables is not the issue, though the feedback is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If anyone has an answer as to why the QUERY in the log that is generated as a result of the macro works perfectly as is, but the macro fails, that would be most appreciated.&amp;nbsp; Thank you.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204931#M38111</guid>
      <dc:creator>D8tAm1n3r_BEN</dc:creator>
      <dc:date>2015-06-12T14:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Syntax Error in Macro Driven PROC SQL Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204932#M38112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To further clarify, I have found a workaround by copying/pasting the code generated in the LOG, so I'm not trying to find alternative solutions.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm just dying to know why PROC SQL is having an issue processing the %DO loop generated statements.&amp;nbsp; We use this technique frequently in our code and have not had this issue before, so we're just curious if anyone knows why.&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 14:38:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204932#M38112</guid>
      <dc:creator>D8tAm1n3r_BEN</dc:creator>
      <dc:date>2015-06-12T14:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Syntax Error in Macro Driven PROC SQL Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204933#M38113</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I suspect it's the quoting character introduced by %QSCAN.&amp;nbsp; SQL sometimes has trouble with parsing when the quoting characters are present.&amp;nbsp; Switch to %SCAN instead and see if that takes care of the problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 15:14:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204933#M38113</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2015-06-12T15:14:18Z</dc:date>
    </item>
    <item>
      <title>Re: Apparent Syntax Error in Macro Driven PROC SQL Statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204934#M38114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You, good SAS user, are a genius!&amp;nbsp; I typically use a CALL EXECUTE in a DATA _NULL_ to control iterative variables but in this case I moved it inside.&amp;nbsp; Thank you for your helpfulness!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2015 15:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Apparent-Syntax-Error-in-Macro-Driven-PROC-SQL-Statement/m-p/204934#M38114</guid>
      <dc:creator>D8tAm1n3r_BEN</dc:creator>
      <dc:date>2015-06-12T15:18:53Z</dc:date>
    </item>
  </channel>
</rss>

