<?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: Stored Process - macro variable list used in WHERE IN condition in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485505#M126146</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;you are right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say i have found a 80% of the solution in this post:&lt;/P&gt;&lt;P&gt;&lt;A href="http://bi-notes.com/2013/08/sas-stored-process-taming-selection-list-prompts/" target="_blank"&gt;http://bi-notes.com/2013/08/sas-stored-process-taming-selection-list-prompts/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still have a problem because the value in the list promt i submit to the stored procedure is like&amp;nbsp;"Some Some", without double quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i fix this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Aug 2018 14:57:08 GMT</pubDate>
    <dc:creator>gabras</dc:creator>
    <dc:date>2018-08-09T14:57:08Z</dc:date>
    <item>
      <title>Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485393#M126107</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm writing stored procedure in wich i have to pass a list of values in order to use it as a parameter and then use this parameter in a WHERE IN clause.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create a prompt fromlist = 'a','b','c','d',e' which is its default value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro filter(fromlist);&lt;/P&gt;&lt;P&gt;&amp;nbsp;proc sql;&lt;/P&gt;&lt;P&gt;select * from have&lt;/P&gt;&lt;P&gt;WHERE var IN (&amp;amp;fromlist);&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%mend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%filter( fromlist = &amp;amp;fromlist)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It result in a error :&lt;/P&gt;&lt;P&gt;&amp;nbsp;ERROR: All positional parameters must precede keyword parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried to use this code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I create a prompt fromlist&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;=&amp;nbsp; &amp;nbsp; &amp;nbsp;var IN ( 'a','b','c','d',e')&amp;nbsp; &amp;nbsp; which is its default value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%macro filter(fromlist);&lt;/P&gt;&lt;P&gt;&amp;nbsp;proc sql;&lt;/P&gt;&lt;P&gt;select * from have&lt;/P&gt;&lt;P&gt;WHERE &amp;amp;fromlist;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;%filter( fromlist = &amp;amp;fromlist)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It result in a error :&lt;/P&gt;&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a string between quotes, a numerical constant, a date and time constant, a missing value, (, -, SELECT.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 10:08:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485393#M126107</guid>
      <dc:creator>gabras</dc:creator>
      <dc:date>2018-08-09T10:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485397#M126108</link>
      <description>&lt;P&gt;The reason is, is that commas delineate parameters in a macro call so your first call looks like:&lt;BR /&gt;&lt;SPAN&gt;%filter( fromlist = 'a','b','c','d',e')&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do from list is 'a' then you have four parameters which are not in the macro.&amp;nbsp; You also have unbalanced quotes - note the e' and a missing semicolon etc..&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Also it is a very bad idea to put quotes (especially) and commas in macro variables.&amp;nbsp; Simplify&amp;nbsp;your prompt to accept a list of space delimited non-quoted values and use that:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;%let fromlist=a b c d e;

%macro filter(fromlist);&lt;BR /&gt;
  proc sql;
    select * 
    from have
    where var in (&amp;amp;fromlist.);
  quit;&lt;BR /&gt;
%mend;

%filter(fromlist=&amp;amp;fromlist.);&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Also note how I use consistent casing, indentation and finish macro variables with a . so that the code is nice and easy to read.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Do be careful naming the macro variable the same as the internal macro variable, it works here because of scope, but if the first on outside the macro was created gloabally...&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 10:24:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485397#M126108</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-09T10:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485398#M126109</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&lt;/P&gt;&lt;P&gt;unfortunately it doensn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;280 %filter ( data_da= &amp;amp;DATA_DA ,&lt;BR /&gt;281 data_a = &amp;amp;DATA_A,&lt;BR /&gt;282 fromlist= &amp;amp;&lt;SPAN&gt;fromlist&lt;/SPAN&gt;.);&lt;BR /&gt;ERROR: All positional parameters must precede keyword parameters.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"a", "b","c","(here there is the reference of the error to the " )d", ...&lt;/P&gt;&lt;P&gt;ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 10:39:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485398#M126109</guid>
      <dc:creator>gabras</dc:creator>
      <dc:date>2018-08-09T10:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485401#M126110</link>
      <description>&lt;P&gt;Perhaps re-read my post, you still have a macro variable with quotes and commas in it.&amp;nbsp; Plus you still have the errors which I pointed out to you.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 10:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485401#M126110</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-09T10:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485404#M126113</link>
      <description>&lt;P&gt;As soon as you correct the missing single quote, your second code works:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input var $;
cards;
a
b
c
d
e
f
g
h
i
j
;
run;

%let fromlist = var IN ('a','b','c','d','e');

%macro filter(fromlist);
proc sql;
select * from have
where &amp;amp;fromlist;
quit;
%mend;

%filter(fromlist = &amp;amp;fromlist)&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;var
--------
a       
b       
c       
d       
e       
&lt;/PRE&gt;</description>
      <pubDate>Thu, 09 Aug 2018 10:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485404#M126113</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-09T10:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485436#M126126</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i'm using promp given by stored process wizard in SAS EG.&lt;/P&gt;&lt;P&gt;The values in the macro variable list are something like:&amp;nbsp; &amp;nbsp;abc bcd; efg hil; mno pqr;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;i really don't understand how your suggestion can fit in the where in caondition. maybe i'm missing something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;that code doesn't work. i don't kow why but maybe becasue i'm running a stored process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32"&gt;@BrunoMueller&lt;/a&gt;&amp;nbsp;help us please&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 12:32:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485436#M126126</guid>
      <dc:creator>gabras</dc:creator>
      <dc:date>2018-08-09T12:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485444#M126128</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/121210"&gt;@gabras&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;that code doesn't work. i don't kow why but maybe becasue i'm running a stored process.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And? Where is the log?&lt;/P&gt;
&lt;P&gt;See &lt;A href="http://support.sas.com/documentation/cdl/en/stpug/61271/HTML/default/viewer.htm#exam.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/stpug/61271/HTML/default/viewer.htm#exam.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;"Does not work" on its own is THE most useless statement we come across here.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 12:45:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485444#M126128</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-09T12:45:53Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485452#M126132</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the errors of the log are the same that I reported in my first post, since i tried the code you suggested.&lt;BR /&gt;Actually it's my fault that I did not specify that the missing single quote was a typo.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 12:58:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485452#M126132</guid>
      <dc:creator>gabras</dc:creator>
      <dc:date>2018-08-09T12:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485477#M126142</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30742"&gt;@DavidRice&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;could you help&amp;nbsp; me?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 14:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485477#M126142</guid>
      <dc:creator>gabras</dc:creator>
      <dc:date>2018-08-09T14:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485484#M126143</link>
      <description>&lt;P&gt;"The log" is not just the error message. The log is the&amp;nbsp;&lt;EM&gt;whole&lt;/EM&gt; log text of your macro definition and macro call. By withholding crucial information, you make it hard for us to help you.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 14:09:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485484#M126143</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-08-09T14:09:36Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485505#M126146</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;you are right.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let's say i have found a 80% of the solution in this post:&lt;/P&gt;&lt;P&gt;&lt;A href="http://bi-notes.com/2013/08/sas-stored-process-taming-selection-list-prompts/" target="_blank"&gt;http://bi-notes.com/2013/08/sas-stored-process-taming-selection-list-prompts/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still have a problem because the value in the list promt i submit to the stored procedure is like&amp;nbsp;"Some Some", without double quotes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can i fix this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 14:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485505#M126146</guid>
      <dc:creator>gabras</dc:creator>
      <dc:date>2018-08-09T14:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Stored Process - macro variable list used in WHERE IN condition</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485794#M126259</link>
      <description>&lt;P&gt;Please provide screenshots of your parameter/prompt definition within the Stored Process. We need both information, the General with type etc., as well as the Prompt Type and Values definition&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you using SAS Enterprise Guide to develop your Stored Process?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 14:46:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Stored-Process-macro-variable-list-used-in-WHERE-IN-condition/m-p/485794#M126259</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2018-08-10T14:46:35Z</dc:date>
    </item>
  </channel>
</rss>

