<?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 ID list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541405#M149467</link>
    <description>&lt;P&gt;If no observations are returned by the query then the SQL INTO clause does not create the macro variable.&lt;/P&gt;
&lt;P&gt;Set the macro variable to a default value before the query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test3_list=;
select ... into :test3_list separated by ' ' ....;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then later on make sure you don't end up with commas with nothing between them.&amp;nbsp; Since SAS doesn't need the commas between the values used in the list of values passed to the IN operator just don't include them. Use spaces as the delimiter instead. Multiple adjacent spaces do not cause any trouble.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if caseid in (&amp;amp;test1_list.  &amp;amp;test2_list. &amp;amp;test3_list.  &amp;amp;test4_list.) then output want;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Mar 2019 14:18:51 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2019-03-08T14:18:51Z</dc:date>
    <item>
      <title>Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541397#M149462</link>
      <description>&lt;P&gt;Hi experts:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I created several macro ID lists from different test datasets, such as test 1, test 2, test 3 and test 4.&amp;nbsp; I would like to do the following, however, I found error message from my lot window.&amp;nbsp; Any idea why and how to fix it?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
	select quote(strip(id)) into : test1_list separated by ',' from test1;
quit;
 
%put &amp;amp;test1_list;
.
.
proc sql noprint;
	select quote(strip(id)) into : test4_list separated by ',' from test4;
quit;
 
%put &amp;amp;test4_list;

data want;
	set have;
	if caseid in (&amp;amp;test1_list., &amp;amp;test2_list., &amp;amp;test3_list.,  &amp;amp;test4_list.) then output want;
	if caseid in (&amp;amp;test1_list) then Mark = 1;
	if caseid in (&amp;amp;test2_list) then Mark = 2;
	if caseid in (&amp;amp;test3_list) then Mark = 3;
	if caseid in (&amp;amp;test4_list) then Mark = 4;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;92 data have;&lt;BR /&gt;93 set want;&lt;BR /&gt;94 if caseid in (&amp;amp;test1_list., &amp;amp;test2_list.,&lt;BR /&gt;94 ! &amp;amp;test3_list., &amp;amp;test4_list.) then output have;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 22&lt;BR /&gt;WARNING: Apparent symbolic reference test3_LIST not resolved.&lt;BR /&gt;94 &amp;amp;test3_list., &amp;amp;test4_list.) then output&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 200&lt;BR /&gt;94 ! want;&lt;BR /&gt;ERROR: All variables in array list must be the same type, i.e., all numeric or character.&lt;BR /&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, iterator, (.&lt;/P&gt;
&lt;P&gt;ERROR 200-322: The symbol is not recognized and will be ignored.&lt;/P&gt;
&lt;P&gt;95 if caseid in (&amp;amp;test1_list) then Mark = 1;&lt;BR /&gt;96 if caseid in (&amp;amp;test2_list) then Mark = 2;&lt;BR /&gt;97 if caseid in (&amp;amp;test3_list) then Mark = 3;&lt;BR /&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;-&lt;BR /&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;22&lt;BR /&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;76&lt;BR /&gt;WARNING: Apparent symbolic reference test3_LIST not resolved.&lt;BR /&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, iterator, (.&lt;/P&gt;
&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;
&lt;P&gt;98 if caseid in (&amp;amp;test4_list) then Mark = 4;&lt;BR /&gt;99 run;&lt;/P&gt;
&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 13:34:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541397#M149462</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2019-03-08T13:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541400#M149464</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;94 ! &amp;amp;test3_list., &amp;amp;test4_list.) then output have;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; 22&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WARNING: Apparent symbolic reference test3_LIST not resolved.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;94 &amp;amp;test3_list., &amp;amp;test4_list.) then output&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Obviously, Test3_List is not resolved, and that happens because Test3_List does not exist; but you need to show us the SAS Log of the entire program, not just the few lines of code where the error is. Furthermore, you need to paste the entire text of your SAS log into the window that appears when you click on the {i} icon DO NOT SKIP THIS STEP.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 13:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541400#M149464</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-08T13:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541401#M149465</link>
      <description>&lt;P&gt;Does&amp;nbsp;&amp;amp;&lt;SPAN&gt;test3_LIST have a value? Can you print out a sample of the values for all 4 of your test&amp;lt;#&amp;gt;_LIST's?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 13:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541401#M149465</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-03-08T13:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541405#M149467</link>
      <description>&lt;P&gt;If no observations are returned by the query then the SQL INTO clause does not create the macro variable.&lt;/P&gt;
&lt;P&gt;Set the macro variable to a default value before the query.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let test3_list=;
select ... into :test3_list separated by ' ' ....;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then later on make sure you don't end up with commas with nothing between them.&amp;nbsp; Since SAS doesn't need the commas between the values used in the list of values passed to the IN operator just don't include them. Use spaces as the delimiter instead. Multiple adjacent spaces do not cause any trouble.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if caseid in (&amp;amp;test1_list.  &amp;amp;test2_list. &amp;amp;test3_list.  &amp;amp;test4_list.) then output want;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 14:18:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541405#M149467</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-03-08T14:18:51Z</dc:date>
    </item>
    <item>
      <title>Re: Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541406#M149468</link>
      <description>&lt;P&gt;Below is&amp;nbsp;the examples of test3 ID list after creating a macro.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"PR8G00225","KW1H55007"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 14:02:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541406#M149468</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2019-03-08T14:02:37Z</dc:date>
    </item>
    <item>
      <title>Re: Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541409#M149469</link>
      <description>&lt;P&gt;Still refusing to use plain code then?&lt;/P&gt;
&lt;PRE&gt;data code_lists;
  set test1 (in=a)
      test2 (in=b)
      test3 (in=c)
      test4 (in=d);
  if a then mark=1;
  if b then mark=2;
  if c then mark=3;
  if d then mark=4;
run;

data want;
  merge have (in=a)
        code_lists (in=b rename=(id=caseid));
  by caseid;
  if a and b;
run;&lt;/PRE&gt;
&lt;P&gt;Sorting the first dataset out correctly so you have one datasource with the grouping - i.e. mark variable in this case - is the only long winded part of this process, and it is there because you have taken the decision to split up like data - which is never a good idea.&amp;nbsp; Learn to model data well, and coding will become far simpler, more robust, and macro can be forgotten.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 14:20:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541409#M149469</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2019-03-08T14:20:31Z</dc:date>
    </item>
    <item>
      <title>Re: Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541423#M149475</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Below is&amp;nbsp;the examples of test3 ID list after creating a macro.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;"PR8G00225","KW1H55007"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;This doesn't help. When a user says the macro variable exists, and SAS says that it does not exist (cannot be resolved), then I believe SAS. Therefore ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;We need to see the entire SAS log, pasted into the window that appears by clicking on the {i} icon.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Mar 2019 16:18:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541423#M149475</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-03-08T16:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Macro ID list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541612#M149560</link>
      <description>What happens if an ID is in multiple lists? Why do you have commas as the separator, none are needed? &lt;BR /&gt;&lt;BR /&gt;SAS does't think your macro variable exists so you're doing something wrong there but without the full code we can't tell you what, so you'll need to debug it yourself or post your full code and log.</description>
      <pubDate>Fri, 08 Mar 2019 21:09:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-ID-list/m-p/541612#M149560</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-03-08T21:09:29Z</dc:date>
    </item>
  </channel>
</rss>

