<?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 % If statement not valid in open code in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27295#M4948</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'm editing a SAS program I have to include new criteria.&amp;nbsp; I have an instance where only some of the diagnoses will be for some diagnosis types and the rest for others and wish to set the code accordingly but get the error message above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the report I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;%let dxlist = 'I099','I255','I420','I425','I426','I427','I428','I429','I43','I50','P290',&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'F00','F01','F02','F03','F051','G30','G311';&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;%if &amp;amp;dxlist in 'I420' 'I425' 'I426' then %then %do:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I use it in the program like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;25&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; (diagcde{i} ne &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; j=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;25&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; (diagcde{j} ne &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; flag_type6 ne &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; and dx_type(i) in (&amp;amp;dxtypelista) and diagcde(i) in: (&amp;amp;dxlist) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; diagcde(i)=diagcde(j) and dx_type(j) in (&amp;amp;dxtypelistb)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; diagcde(i)=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;" "&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;end&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;﻿The error message is indicating that "%if statement is not valid in open code" nor is the %else but what does this mean and how can I edit above to work?&amp;nbsp; &lt;/P&gt;&lt;P&gt;﻿&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any and all assistance. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 09 Mar 2012 19:30:10 GMT</pubDate>
    <dc:creator>shellp55</dc:creator>
    <dc:date>2012-03-09T19:30:10Z</dc:date>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27295#M4948</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'm editing a SAS program I have to include new criteria.&amp;nbsp; I have an instance where only some of the diagnoses will be for some diagnosis types and the rest for others and wish to set the code accordingly but get the error message above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the report I have:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;%let dxlist = 'I099','I255','I420','I425','I426','I427','I428','I429','I43','I50','P290',&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;'F00','F01','F02','F03','F051','G30','G311';&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;%if &amp;amp;dxlist in 'I420' 'I425' 'I426' then %then %do:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let &lt;SPAN style="font-size: 10pt; font-family: Courier New;"&gt;dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then I use it in the program like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;25&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; (diagcde{i} ne &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; j=&lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;25&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; (diagcde{j} ne &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; flag_type6 ne &lt;/SPAN&gt;&lt;STRONG style="color: teal; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; and dx_type(i) in (&amp;amp;dxtypelista) and diagcde(i) in: (&amp;amp;dxlist) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; diagcde(i)=diagcde(j) and dx_type(j) in (&amp;amp;dxtypelistb)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; diagcde(i)=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;" "&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;end&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;﻿&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;﻿The error message is indicating that "%if statement is not valid in open code" nor is the %else but what does this mean and how can I edit above to work?&amp;nbsp; &lt;/P&gt;&lt;P&gt;﻿&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any and all assistance. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:30:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27295#M4948</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2012-03-09T19:30:10Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27296#M4949</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;dxlist in 'I420' 'I425' 'I426' then %then %do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/P&gt;&lt;P&gt; %mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; %test&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Open code means anywhere out of the box of %macro xxx;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to %mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27296#M4949</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-09T19:36:04Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27297#M4950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wow, thanks for the super speedy reply!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry, but I should have explained that I am very new to macros so I'm not understanding what you've provided....can you please explain?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:42:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27297#M4950</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2012-03-09T19:42:16Z</dc:date>
    </item>
    <item>
      <title>Re: % If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27298#M4951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many macro statements can NOT be used out of macro definition. So you will have to put all of these macro statements inside the macro definition:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test; /*this is the beginning of macro definition, the name of macro is 'test'*/&lt;/P&gt;&lt;P&gt;blah;&lt;/P&gt;&lt;P&gt;blah ;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend; /*this is the end of macro definition*/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/*then if you call it when you decide to excute it*/&lt;/P&gt;&lt;P&gt;%test&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Therefore you need to put&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;dxlist in 'I420' 'I425' 'I426' then %then %do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %let dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;inside your macro definition. BTW, in this case, you need %end to complete the %do loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27298#M4951</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-09T19:50:05Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27299#M4952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Super, thanks so much.&amp;nbsp; I apologize but in my example, I didn't include the "else" statement for the macro.&amp;nbsp; Based on your response, I currently have it written as:&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &amp;amp;dxlist in &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;'I420&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;' 'I425'&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;'I426' &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;then &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; dxtypelista='1' 'W' 'X' 'Y';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;%&lt;STRONG&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I get the error message "there is no matching %if statement for the %else.&amp;nbsp; A dummy macro will be compiled."&amp;nbsp; What should it be?&amp;nbsp; Thanks.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 19:58:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27299#M4952</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2012-03-09T19:58:39Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27300#M4953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;dxlist in 'I420' 'I425' 'I426' then %then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%else %let dxtypelista='1' 'W' 'X' 'Y';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have removed %do in your code, it is not necessary in your context. if you use it, you need to add %end to complete the loop,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;dxlist in 'I420' 'I425' 'I426' then %then %do;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/P&gt;&lt;P&gt;%end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%else %let dxtypelista='1' 'W' 'X' 'Y';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 20:06:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27300#M4953</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-09T20:06:26Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27301#M4954</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry but I'm confused:&amp;nbsp; you indicated you took the "do" statement out so I assumed you wanted me to use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;dxlist in 'I420' 'I425' 'I426' then %then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%else %let dxtypelista='1' 'W' 'X' 'Y';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&amp;nbsp; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Doing that produces the error " &lt;SPAN style="font-size: 8pt;"&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;A character operand was found in the %EVAL function or %IF condition where a numeric &lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;operand is required. The condition was: &amp;amp;dxlist in 'I420' 'I425' 'I426'".&amp;nbsp; Please note that the list is actually longer than the 3 codes used in the example so could moving the next line without a comma or anything be an issue?&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt; font-family: 'SAS Monospace';"&gt;Thanks so much for helping me.&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 20:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27301#M4954</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2012-03-09T20:16:44Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27302#M4955</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You both have then %then in the first line. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is that something specific to Macro code?&lt;/P&gt;&lt;P&gt;Also verify that for in you have minoperator options set appropriately for your code. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OT it looks a possible lookup based on diag codes so you might want to set up a table that you can query from rather than hardcode the macro variables but programmers choice &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 20:19:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27302#M4955</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-03-09T20:19:33Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27303#M4956</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%macro test;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%if &amp;amp;dxlist in 'I420' 'I425' 'I426'&amp;nbsp; %then&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let dxtypelista='1' 'W' 'X' 'Y' '3';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%else %let dxtypelista='1' 'W' 'X' 'Y';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%test;&lt;/P&gt;&lt;P&gt;Reeza is right. you have a 'then' , which does not belong to macro, therefore need to removed. Sorry I overlooked that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 20:26:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27303#M4956</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-03-09T20:26:15Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27304#M4957</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi Reeza&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for responding.&amp;nbsp; Please note that taking out the %then causes the error of where is %then so it must be required.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, the reason I've included the diagnosis codes for look up is because a diagnosis could be present on the chart more than once and I'm only interested in comorbid conditions.&amp;nbsp; So I have to apply the filter of certain diagnoses not both types of 1, w, x, y and M or type 2.&amp;nbsp; So the program throws out all of the scenarios as described and then I'm only evaluating based on what remains and can say if&amp;nbsp; code in ('I420' 'I425' 'I426') then chf=1.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 20:29:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27304#M4957</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2012-03-09T20:29:12Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27305#M4958</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You need the %then but not the 'then' prior to that. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In macro code most of the if/then/else logic you add a % in front of to make it work, ie %if, %then.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't understand this line still though:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;dxlist in 'I420' 'I425' 'I426'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;amp;dxlist is a set of codes and the in is a set of codes, I'm not sure how that will evaluate and I can't see it ever evaluating as true&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 20:52:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27305#M4958</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-03-09T20:52:52Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27306#M4959</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; HI Reeza&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for continuing to help!&amp;nbsp; What I'm trying to do with the &amp;amp;dxlist in 'I420' 'I425' 'I426' is that if the list of codes being reviewed in the code below are from this list of diagnoses then dxtypelista needs to include type 3 but if not then don't look for where type 3.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; i=&lt;/SPAN&gt;&lt;STRONG style="font-size: 10pt; color: teal; font-family: 'Courier New'; background-color: white;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="font-size: 10pt; color: teal; font-family: 'Courier New'; background-color: white;"&gt;25&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; (diagcde{i} ne &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; j=&lt;/SPAN&gt;&lt;STRONG style="font-size: 10pt; color: teal; font-family: 'Courier New'; background-color: white;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;to&lt;/SPAN&gt; &lt;STRONG style="font-size: 10pt; color: teal; font-family: 'Courier New'; background-color: white;"&gt;25&lt;/STRONG&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;while&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; (diagcde{j} ne &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;' '&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="min-height: 8pt; height: 8pt;"&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; flag_type6 ne &lt;/SPAN&gt;&lt;STRONG style="font-size: 10pt; color: teal; font-family: 'Courier New'; background-color: white;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; and dx_type(i) in (&amp;amp;dxtypelista) and diagcde(i) in: (&amp;amp;dxlist) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; diagcde(i)=diagcde(j) and dx_type(j) in (&amp;amp;dxtypelistb)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; diagcde(i)=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: purple; font-family: 'Courier New'; background-color: white;"&gt;" "&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;end&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How would it make more sense to do?&amp;nbsp; Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 20:57:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27306#M4959</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2012-03-09T20:57:47Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27307#M4960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I should have advised that I was using version 9.1 where the IN statement in macros was deactivated (which I only found out while searching the web to fix my code).&amp;nbsp; So I had to do the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;%macro&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;STRONG&gt;&lt;EM&gt;test&lt;/EM&gt;&lt;/STRONG&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%if&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &amp;amp;dxlist eq I43 or &amp;amp;dxlist eq F00 or &amp;amp;dxlist eq F02 %then&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; dxtypelista= '1' 'W' 'X' 'Y' '3';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%else&lt;/SPAN&gt; &lt;SPAN style="font-size: 10pt; color: blue; font-family: 'Courier New'; background-color: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; dxtypelista= '1' 'W' 'X' 'Y';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; font-size: 10pt; background-color: white; font-family: 'Courier New';"&gt;%mend&lt;/STRONG&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; test;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt;This is rather bulky but until I install 9.3 it will have to do. Thanks Reeza and &lt;/SPAN&gt;Haikuo for your assistance.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; color: black; font-family: 'Courier New'; background-color: white;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 22:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27307#M4960</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2012-03-09T22:03:58Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27308#M4961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jive-link-external-small" href="http://studysas.blogspot.com/2009/08/macro-in-operator.html"&gt;http://studysas.blogspot.com/2009/08/macro-in-operator.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 09 Mar 2012 22:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27308#M4961</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-03-09T22:35:24Z</dc:date>
    </item>
    <item>
      <title>% If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27309#M4962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt; Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Maybe I was bug eyed from working on this for so long but I thought my version worked.&amp;nbsp; Anyway, when I ran it again it wasn't working but in looking at your suggestion it isn't working either and produced the error message "&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;Macro keyword IF appears as text.&amp;nbsp; A semicolon or other delimiter may be missing."&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: Arial;"&gt;I'm stumped on this so any assistance greatly appreciated.&amp;nbsp; Thanks.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Mar 2012 03:14:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27309#M4962</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2012-03-10T03:14:57Z</dc:date>
    </item>
    <item>
      <title>Re: % If statement not valid in open code</title>
      <link>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27310#M4963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sounds like you need to learn about how SAS macros work. The main thing to understand is that the macro logic just generates text that is then treated by plain old SAS the same as if that text had been typed as the original program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you even have a macro to begin with in the original program that you are trying to update?&lt;/P&gt;&lt;P&gt;The snippet of code you included in your original code is normal SAS code that would be part of a DATA step.&amp;nbsp; It is using macro VARIABLES to store values so that the code is little easier to edit, but it did not include any conditional logic (MACRO logic) that would require that it be part of a macro rather than open code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The main problem with your attempt to modify the program is the LOGIC of what you are trying to do.&amp;nbsp; You appear to want to test if one list is in another list.&amp;nbsp; That syntax does not even exist. What did you mean by the condition (&lt;SPAN style="font-family: Arial; background-color: #eef4f9;"&gt;&amp;amp;dxlist in 'I420' 'I425' 'I426' &lt;/SPAN&gt;)?&lt;/P&gt;&lt;P&gt;Are you asking if all of the codes in DXLIST are one of these three codes?&amp;nbsp; Or perhaps the other way around, whether all three of these codes are in DXLIST?&lt;/P&gt;&lt;P&gt;Maybe you want it to be true when any of the codes in DXLIST are in the other list?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you look at the logic of your original data step code you can see that what you need to do is index over one of these lists and compare an individual value from that list to the other list.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you cannot use the IN operator you could probably do what you want using the INDEXW function instead, but you will probably need to remove all of those quotes.&amp;nbsp; For example you could replace ('XYZ' in ('123','abc','XYZ')) with indexw('123 abc XYZ','XYZ').&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 10 Mar 2012 03:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/If-statement-not-valid-in-open-code/m-p/27310#M4963</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-03-10T03:49:26Z</dc:date>
    </item>
  </channel>
</rss>

