<?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 %include - if  condition 1  to execute a sas code 1, else to execute a sas code 2 -- with errors in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652624#M195953</link>
    <description>&lt;P&gt;if&amp;nbsp;&amp;nbsp;any&amp;nbsp;value&amp;nbsp; contains "no"&amp;nbsp; then execute program_1.sas, else execute program_2.sas. the errors " error 180-322:statement is not valid or its is used out or proper order" and error " else&amp;nbsp; statement&amp;nbsp; is not valid or it is used out of proper order. the sample is attached.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Can someone help?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; comp_lst $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;do&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;until&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; (eof);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;keep&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=verified ) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=eof;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;comp_lst=catx(&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;" "&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,comp_lst,verified);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; verified;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(comp_lst,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"no"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%include&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#800080"&gt;"\program_1.sas"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(comp_lst, &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"no"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;lt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%include&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#800080"&gt;"\program_2.sas"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks !&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Jun 2020 17:37:15 GMT</pubDate>
    <dc:creator>GraceStehlin98</dc:creator>
    <dc:date>2020-06-02T17:37:15Z</dc:date>
    <item>
      <title>%include - if  condition 1  to execute a sas code 1, else to execute a sas code 2 -- with errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652624#M195953</link>
      <description>&lt;P&gt;if&amp;nbsp;&amp;nbsp;any&amp;nbsp;value&amp;nbsp; contains "no"&amp;nbsp; then execute program_1.sas, else execute program_2.sas. the errors " error 180-322:statement is not valid or its is used out or proper order" and error " else&amp;nbsp; statement&amp;nbsp; is not valid or it is used out of proper order. the sample is attached.&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Can someone help?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;_null_&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;length&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; comp_lst $&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;20&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;do&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;until&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; (eof);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; a (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;keep&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=verified ) &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=eof;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2"&gt;comp_lst=catx(&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;" "&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,comp_lst,verified);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;end&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; verified;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(comp_lst,&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"no"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;0&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%include&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#800080"&gt;"\program_1.sas"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;else&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; index(comp_lst, &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;"no"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;)&amp;lt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#008080"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;then&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;%include&lt;/FONT&gt; &lt;FONT face="Courier New" size="2" color="#800080"&gt;"\program_2.sas"&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks !&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 17:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652624#M195953</guid>
      <dc:creator>GraceStehlin98</dc:creator>
      <dc:date>2020-06-02T17:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: %include - if  condition 1  to execute a sas code 1, else to execute a sas code 2 -- with errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652627#M195955</link>
      <description>use call execute functionality when a certain condition is satisfied. it would work.</description>
      <pubDate>Tue, 02 Jun 2020 17:40:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652627#M195955</guid>
      <dc:creator>VENKATAMAHESH</dc:creator>
      <dc:date>2020-06-02T17:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: %include - if  condition 1  to execute a sas code 1, else to execute a sas code 2 -- with errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652633#M195957</link>
      <description>if you have better idea to check a value "no" from the variable "verified", that will be great too!. I don't know why "%include" doesn't work .&lt;BR /&gt;&lt;BR /&gt;Thanks !</description>
      <pubDate>Tue, 02 Jun 2020 17:50:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652633#M195957</guid>
      <dc:creator>GraceStehlin98</dc:creator>
      <dc:date>2020-06-02T17:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: %include - if  condition 1  to execute a sas code 1, else to execute a sas code 2 -- with errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652634#M195958</link>
      <description>&lt;P&gt;I don't think %INCLUDE can be run conditionally. You need to use CALL EXECUTE() instead to call that program.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this maybe:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if index(comp_lst,"no")&amp;gt;0 then call execute('%include "\program_1.sas"; ');

else if index(comp_lst, "no")&amp;lt;1 then call execute('%include "\program_2.sas" ;' );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=p1s3uhhqtscz2sn1otiatbovfn1t.htm&amp;amp;locale=en"&gt;https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.5&amp;amp;docsetId=lestmtsglobal&amp;amp;docsetTarget=p1s3uhhqtscz2sn1otiatbovfn1t.htm&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Because %INCLUDE is a global statement and global statements are not executable, the %INCLUDE statement cannot be used in conditional logic.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 17:52:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652634#M195958</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-02T17:52:51Z</dc:date>
    </item>
    <item>
      <title>Re: %include - if  condition 1  to execute a sas code 1, else to execute a sas code 2 -- with errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652637#M195960</link>
      <description>&lt;P&gt;it works perfectly!&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 18:01:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652637#M195960</guid>
      <dc:creator>GraceStehlin98</dc:creator>
      <dc:date>2020-06-02T18:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: %include - if  condition 1  to execute a sas code 1, else to execute a sas code 2 -- with errors</title>
      <link>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652642#M195962</link>
      <description>&lt;P&gt;&amp;nbsp;Alternative code using macro program:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
   set a (keep=verified ) end=eof;
   comp_lst=catx(" ",comp_lst,verified);
   if eof then do;
      result = index(comp_lst,"no");
	  call symput('result', strip(result));
   end;
run;
%run_program(rc);
   %if &amp;amp;rc &amp;gt; 0 %then %include "\program_1.sas";
   %if &amp;amp;rc &amp;lt; 1 %then %include "\program_2.sas";
%mend run_program;
%run_program(&amp;amp;result);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Jun 2020 18:20:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/include-if-condition-1-to-execute-a-sas-code-1-else-to-execute-a/m-p/652642#M195962</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2020-06-02T18:20:30Z</dc:date>
    </item>
  </channel>
</rss>

