<?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: Where statement could not recognize Macro ID list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-could-not-recognize-Macro-ID-list/m-p/939686#M368934</link>
    <description>&lt;P&gt;Not enough ampersands.&amp;nbsp; Use &amp;amp;&amp;amp;&amp;amp; instead of &amp;amp;&amp;amp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2024 18:36:25 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2024-08-16T18:36:25Z</dc:date>
    <item>
      <title>Where statement could not recognize Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-could-not-recognize-Macro-ID-list/m-p/939676#M368933</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created an ID list below and ran a where statement afterward.&amp;nbsp; However, the error was shown in the log.&amp;nbsp; Please help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data CoV_HA_IDs;
      infile datalines dsd;
  input  ID : $50. ;
datalines;
1110,
1107,
1106,
	;
run;

proc sql;
	select quote(strip(ID)) into : CoV_HA_ID_list separated by ','  from CoV_HA_IDs;
quit;

%put &amp;amp;CoV_HA_ID_list;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Macro aaa (Panel);
proc tabulate data=NREVSS251_vw_&amp;amp;st.;
  class eor_spec_id eot_test_ce1 eot_test_ce2 erv_rslt_ce2;
  table eor_spec_id, eot_test_ce1*eot_test_ce2* (erv_rslt_ce2 all)* (N);
  where eor_spec_id in (&amp;amp;&amp;amp;Panel._ID_list.);
run;
%mend aaa;
%aaa (CoV_HA);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI-SPOILER&gt;
&lt;LI-SPOILER&gt;
&lt;P&gt;SYMBOLGEN: Macro variable ST resolves to UT&lt;BR /&gt;MPRINT(AAA): proc tabulate data=NREVSS251_vw_UT;&lt;BR /&gt;MPRINT(AAA): class eor_spec_id eot_test_ce1 eot_test_ce2 erv_rslt_ce2;&lt;BR /&gt;MPRINT(AAA): table eor_spec_id, eot_test_ce1*eot_test_ce2* (erv_rslt_ce2 all)* (N);&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable PANEL resolves to CoV_HA&lt;BR /&gt;NOTE: Line generated by the macro variable "PANEL".&lt;BR /&gt;1 CoV_HA&lt;BR /&gt;------&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;MPRINT(AAA): where eor_spec_id in (CoV_HA._ID_list.);&lt;BR /&gt;ERROR: Syntax error while parsing WHERE clause.&lt;BR /&gt;MPRINT(AAA): run;&lt;/P&gt;
&lt;P&gt;ERROR 22-322: Syntax error, expecting one of the following: a quoted string, a numeric constant,&lt;BR /&gt;a datetime constant, a missing value, -.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;NOTE: PROCEDURE TABULATE used (Total process time):&lt;BR /&gt;real time 0.00 seconds&lt;BR /&gt;cpu time 0.00 seconds&lt;/P&gt;
&lt;P&gt;MLOGIC(AAA): Ending execution.&lt;/P&gt;
&lt;/LI-SPOILER&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Fri, 16 Aug 2024 18:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-statement-could-not-recognize-Macro-ID-list/m-p/939676#M368933</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2024-08-16T18:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: Where statement could not recognize Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-could-not-recognize-Macro-ID-list/m-p/939686#M368934</link>
      <description>&lt;P&gt;Not enough ampersands.&amp;nbsp; Use &amp;amp;&amp;amp;&amp;amp; instead of &amp;amp;&amp;amp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 18:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-statement-could-not-recognize-Macro-ID-list/m-p/939686#M368934</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-08-16T18:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: Where statement could not recognize Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Where-statement-could-not-recognize-Macro-ID-list/m-p/939687#M368935</link>
      <description>&lt;P&gt;Why do you have two ampersands?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the name of the macro variable is&amp;nbsp;Panel_ID_list then you only want one.&lt;/P&gt;
&lt;P&gt;If the name is being built from the value a macro variable named PANEL then you need three ampersands.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&amp;amp;&amp;amp;&amp;amp;Panel._ID_list&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;On the first pass the macro process will convert &amp;amp;&amp;amp; to &amp;amp; and remind itself to make a second pass.&amp;nbsp; On the first pass it will convert &amp;amp;panel. into the value of PANEL so that when it gets to the second pass the name of the macro variable will be COV_HA_ID_LIST.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PS You usually do NOT want to use STRIP() the way you have when moving character variable values into macro variables.&amp;nbsp; If the actual value has leading spaces then STRIP() will remove them and then the resulting quotes string will no longer match the actual value.&amp;nbsp; Just use TRIM() instead.&amp;nbsp; You also can make the macro variable easier to work with by using space instead of comma as the delimiter.&amp;nbsp; SAS code does not care which you use (or if you combine them).&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;select quote(trim(ID))
   into : CoV_HA_ID_list separated by ' '  
from CoV_HA_IDs
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That way you could just define the macro to expect the actual list of values.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro aaa (id_list);
proc tabulate data=NREVSS251_vw_&amp;amp;st.;
  class eor_spec_id eot_test_ce1 eot_test_ce2 erv_rslt_ce2;
  table eor_spec_id, eot_test_ce1*eot_test_ce2* (erv_rslt_ce2 all)* (N);
  where eor_spec_id in (&amp;amp;id_list);
run;
%mend aaa;
%aaa(&amp;amp;CoV_HA_ID_LIST);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Aug 2024 18:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Where-statement-could-not-recognize-Macro-ID-list/m-p/939687#M368935</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-08-16T18:43:45Z</dc:date>
    </item>
  </channel>
</rss>

