<?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 Macro List Errors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266600#M52582</link>
    <description>&lt;P&gt;I'm trying to leverage the macro list function in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Blocked_Email&lt;/P&gt;&lt;P&gt;josh1@gmail.com&lt;/P&gt;&lt;P&gt;josh3@yahoo.com&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;HAVE&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input ID$ Date:mmddyy10. email_address: $40. acct: $25.;
	format date mmddyy10.;
	cards;
josh 1/1/2015 josh1@gmail.com 0004
josh 1/2/2015 josh2@yahoo.com 0005
josh 1/3/2015 josh3@yahoo.com 0006
mary 1/4/2015 mary123@aol.com 0007
mary 1/5/2015 mars@blah.com 0008
josh 1/6/2015 josh1@gmail.com 0009
josh 1/7/2015 josh2@yahoo.com 0010
josh 1/8/2015 josh3@yahoo.com 0011
mary 1/9/2015 mary123@aol.com 0012
mary 1/10/2015 mars@blah.com 0008
josh 1/11/2015 josh7@gmail.com 0005
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;WANT&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;id date email acct block&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;josh 1/1/2015 josh1@gmail.com 0004&amp;nbsp;email&lt;BR /&gt;josh 1/2/2015 josh2@yahoo.com 0005 notblocked&lt;BR /&gt;josh 1/3/2015 josh3@yahoo.com 0006 email&lt;BR /&gt;mary 1/4/2015 mary123@aol.com 0007 notblocked&lt;BR /&gt;mary 1/5/2015 mars@blah.com 0008 notblocked&lt;BR /&gt;josh 1/6/2015 josh1@gmail.com 0009 email&lt;BR /&gt;josh 1/7/2015 josh2@yahoo.com 0010 notblocked&lt;BR /&gt;josh 1/8/2015 josh3@yahoo.com 0011 email&lt;BR /&gt;mary 1/9/2015 mary123@aol.com 0012 notblocked&lt;BR /&gt;mary 1/10/2015 mars@blah.com 0008 notblocked&lt;BR /&gt;josh 1/11/2015 josh7@gmail.com 0005 notblocked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now my code is set up like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error&amp;nbsp;&lt;/P&gt;&lt;P&gt;24 if upcase(Email_address) in (&amp;amp;BlockedEmail.) then Block='Email';&lt;BR /&gt;NOTE: Line generated by the macro variable "BLOCKEDEMAIL".&lt;BR /&gt;24 josh1@gmail.com ,josh2@yahoo.com ,josh3@yahoo.com&lt;BR /&gt;_____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;24 ! ,josh7@gmail.com ,mars@blah.com ,mary123@aol.com&lt;BR /&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, iterator, (.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;25 ;run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0 observations and 5 variables.&lt;BR /&gt;WARNING: Data set WORK.TEST was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Type2:Email*/
proc sql;
select distinct email_address into :BlockedEmail seperated by ',' notrim
from have
/*where BlockedTypeId=2 ;*/
;quit; 
/*test*/
data Test;
	set have;
    Block='NotBlocked';
	if upcase(Email_address) in (&amp;amp;BlockedEmail.) then Block='Email';
	;run; 
proc print data=test;run&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 27 Apr 2016 02:05:56 GMT</pubDate>
    <dc:creator>JS</dc:creator>
    <dc:date>2016-04-27T02:05:56Z</dc:date>
    <item>
      <title>Macro List Errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266600#M52582</link>
      <description>&lt;P&gt;I'm trying to leverage the macro list function in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Blocked_Email&lt;/P&gt;&lt;P&gt;josh1@gmail.com&lt;/P&gt;&lt;P&gt;josh3@yahoo.com&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;HAVE&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	input ID$ Date:mmddyy10. email_address: $40. acct: $25.;
	format date mmddyy10.;
	cards;
josh 1/1/2015 josh1@gmail.com 0004
josh 1/2/2015 josh2@yahoo.com 0005
josh 1/3/2015 josh3@yahoo.com 0006
mary 1/4/2015 mary123@aol.com 0007
mary 1/5/2015 mars@blah.com 0008
josh 1/6/2015 josh1@gmail.com 0009
josh 1/7/2015 josh2@yahoo.com 0010
josh 1/8/2015 josh3@yahoo.com 0011
mary 1/9/2015 mary123@aol.com 0012
mary 1/10/2015 mars@blah.com 0008
josh 1/11/2015 josh7@gmail.com 0005
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;WANT&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;id date email acct block&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;josh 1/1/2015 josh1@gmail.com 0004&amp;nbsp;email&lt;BR /&gt;josh 1/2/2015 josh2@yahoo.com 0005 notblocked&lt;BR /&gt;josh 1/3/2015 josh3@yahoo.com 0006 email&lt;BR /&gt;mary 1/4/2015 mary123@aol.com 0007 notblocked&lt;BR /&gt;mary 1/5/2015 mars@blah.com 0008 notblocked&lt;BR /&gt;josh 1/6/2015 josh1@gmail.com 0009 email&lt;BR /&gt;josh 1/7/2015 josh2@yahoo.com 0010 notblocked&lt;BR /&gt;josh 1/8/2015 josh3@yahoo.com 0011 email&lt;BR /&gt;mary 1/9/2015 mary123@aol.com 0012 notblocked&lt;BR /&gt;mary 1/10/2015 mars@blah.com 0008 notblocked&lt;BR /&gt;josh 1/11/2015 josh7@gmail.com 0005 notblocked&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Right now my code is set up like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get this error&amp;nbsp;&lt;/P&gt;&lt;P&gt;24 if upcase(Email_address) in (&amp;amp;BlockedEmail.) then Block='Email';&lt;BR /&gt;NOTE: Line generated by the macro variable "BLOCKEDEMAIL".&lt;BR /&gt;24 josh1@gmail.com ,josh2@yahoo.com ,josh3@yahoo.com&lt;BR /&gt;_____&lt;BR /&gt;22&lt;BR /&gt;76&lt;BR /&gt;24 ! ,josh7@gmail.com ,mars@blah.com ,mary123@aol.com&lt;BR /&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, iterator, (.&lt;/P&gt;&lt;P&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/P&gt;&lt;P&gt;25 ;run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0 observations and 5 variables.&lt;BR /&gt;WARNING: Data set WORK.TEST was not replaced because this step was stopped.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Type2:Email*/
proc sql;
select distinct email_address into :BlockedEmail seperated by ',' notrim
from have
/*where BlockedTypeId=2 ;*/
;quit; 
/*test*/
data Test;
	set have;
    Block='NotBlocked';
	if upcase(Email_address) in (&amp;amp;BlockedEmail.) then Block='Email';
	;run; 
proc print data=test;run&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 02:05:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266600#M52582</guid>
      <dc:creator>JS</dc:creator>
      <dc:date>2016-04-27T02:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: Macro List Errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266604#M52586</link>
      <description>&lt;P&gt;Ahhh I figured it out!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It appears that the list must be updated with a quotation mark at the begininng and end to denote the character string search.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select distinct '"'||upcase(email_address)||'"' into :BlockedEmail separated by ','
from blocked_email
/*where BlockedTypeId=2 ;*/
;quit; 
%put &amp;amp;BlockedEmail;
/*test*/
data Test;
	set have;
    Block='NotBlocked';
	if upcase(Email_address) in (&amp;amp;BlockedEmail.) then Block='Email';
	;run; 
proc print data=test;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 02:21:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266604#M52586</guid>
      <dc:creator>JS</dc:creator>
      <dc:date>2016-04-27T02:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: Macro List Errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266605#M52587</link>
      <description>&lt;P&gt;Use the quote function instead.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Select quote(upcase(email_address)) into :email_list separated by " "&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 02:31:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266605#M52587</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-27T02:31:43Z</dc:date>
    </item>
    <item>
      <title>Re: Macro List Errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266618#M52591</link>
      <description>Hey Reeza,&lt;BR /&gt;&lt;BR /&gt;What are your thoughts on using the quotes vs the appending that I used&lt;BR /&gt;above? Is one more efficient?&lt;BR /&gt;&lt;BR /&gt;##- Please type your reply above this line. Simple formatting, no&lt;BR /&gt;attachments. -##</description>
      <pubDate>Wed, 27 Apr 2016 04:26:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266618#M52591</guid>
      <dc:creator>JS</dc:creator>
      <dc:date>2016-04-27T04:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: Macro List Errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266619#M52592</link>
      <description>&lt;P&gt;One is significantly easier to read &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even if I were to concatenate I recommend the CAT family of functions instead of double pipes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 04:46:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266619#M52592</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-04-27T04:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Macro List Errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266624#M52594</link>
      <description>&lt;P&gt;Thank you Reeza.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a beginner, so they &lt;EM&gt;ALL&amp;nbsp;&lt;/EM&gt;look very difficult to read (:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am still trying to get an eye for what is intuitive to other users vs. what is intuitive just for me, and all your help is realy amazing! Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Apr 2016 06:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266624#M52594</guid>
      <dc:creator>JS</dc:creator>
      <dc:date>2016-04-27T06:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: Macro List Errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266650#M52602</link>
      <description>&lt;P&gt;Why are you using macros at all? &amp;nbsp;What you have is two sets of Data - the dataset of blocked emails, and the dataset of emails. &amp;nbsp;Thus, the simple Base SAS approach is to merge the blocked dataset onto the email dataset and assign a flag based on that, simpple expandable Base SAS code. &amp;nbsp;Some examples of the many ways you can achieve this:&lt;/P&gt;
&lt;PRE&gt;data have;
  input id$ date:mmddyy10. email_address: $40. acct: $25.;
  format date mmddyy10.;
  cards;
josh 1/1/2015 josh1@gmail.com 0004
josh 1/2/2015 josh2@yahoo.com 0005
josh 1/3/2015 josh3@yahoo.com 0006
mary 1/4/2015 mary123@aol.com 0007
mary 1/5/2015 mars@blah.com 0008
josh 1/6/2015 josh1@gmail.com 0009
josh 1/7/2015 josh2@yahoo.com 0010
josh 1/8/2015 josh3@yahoo.com 0011
mary 1/9/2015 mary123@aol.com 0012
mary 1/10/2015 mars@blah.com 0008
josh 1/11/2015 josh7@gmail.com 0005
;
run;
data blocked;
  blocked_email="josh1@gmail.com"; output;
  blocked_email="josh3@yahoo.com"; output;
run;
proc sql;
  create table WANT as
  select  A.*,
          case when B.BLOCKED_EMAIL is not null then "email"
               else "notblocked" end as FLAG
  from    WORK.HAVE A
  left join WORK.BLOCKED B
  on      A.EMAIL_ADDRESS=B.BLOCKED_EMAIL;
quit;
/* Or */
proc sql;
  create table WANT as
  select  A.*,
          case when exists(select distinct BLOCKED_EMAIL from WORK.BLOCKED where BLOCKED_EMAIL=A.EMAIL_ADDRESS) then "email"
               else "notblocked" end as FLAG
  from    WORK.HAVE A;
quit;
/* Or */
proc sort data=have;
  by email_address;
run;
data want;
  length flag $20;
  merge have (in=a) blocked (in=b rename=(blocked_email=email_address));
  by email_address;
  if a and b then flag="email";
  else flag="notblocked";
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Apr 2016 08:48:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/266650#M52602</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-04-27T08:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Macro List Errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/267758#M52953</link>
      <description>&lt;P&gt;That's a great approach to the problem. I was more looking to leverage different functions and expand my base knowlege of what's available in SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All your solutions are certainly very intuitive, and would definitely make excellent work of the query. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 03 May 2016 00:02:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Macro-List-Errors/m-p/267758#M52953</guid>
      <dc:creator>JS</dc:creator>
      <dc:date>2016-05-03T00:02:14Z</dc:date>
    </item>
  </channel>
</rss>

