<?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: Funny quirk of open code %IF in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782405#M249413</link>
    <description>&lt;P&gt;Well, it's a workaround, but clearly not a solution. This is a bug and needs fixing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The fact that this was reported with M5 and is not yet fixed is somewhat disturbing. After all, we always tend to brag about SAS' software quality to beginners and outsiders.&lt;/P&gt;</description>
    <pubDate>Thu, 25 Nov 2021 07:25:17 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-11-25T07:25:17Z</dc:date>
    <item>
      <title>Funny quirk of open code %IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782247#M249382</link>
      <description>&lt;P&gt;While %IF in open code also allows to use %ELSE, it does not work in all circumstances:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let control=Y;

data
%if &amp;amp;control = X
%then %do;
  work.check
%end;
%else %do;
  work.test
%end;
;
x = 1;
run;

data
%if &amp;amp;control = X
%then %do;
  work.check
%end;
%if &amp;amp;control ne X
%then %do;
  work.test
%end;
;
x = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The first data step will fail with a component object failure (but not a macro ERROR message!), while the second works.&lt;/P&gt;
&lt;P&gt;Tested on SAS On Demand, and also 9.4TS1M7 on AIX&lt;/P&gt;</description>
      <pubDate>Wed, 24 Nov 2021 16:41:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782247#M249382</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-24T16:41:40Z</dc:date>
    </item>
    <item>
      <title>Re: Funny quirk of open code %IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782279#M249383</link>
      <description>&lt;P&gt;&lt;A href="https://support.sas.com/kb/65/310.html" target="_self"&gt;Problem Note 65310: An error message occurs when you use %IF-%THEN/%ELSE and %DO macro statements in open code&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here's your code "fixed" as suggested in the Problem Note&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;131  %let control=Y;
132  options mprint symbolgen mlogic ;
133
134  %if &amp;amp;control = X
SYMBOLGEN:  Macro variable CONTROL resolves to Y
135  %then %do;
136    data work.check ;
137  %end;
138  %else %do;
139    data work.test ;
140  %end;
141  ;
142  x = 1;
143  run;

NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Nov 2021 17:39:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782279#M249383</guid>
      <dc:creator>AMSAS</dc:creator>
      <dc:date>2021-11-24T17:39:16Z</dc:date>
    </item>
    <item>
      <title>Re: Funny quirk of open code %IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782388#M249400</link>
      <description>&lt;P&gt;So open code %if can only be used to add statement, or at least statement endings?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This works for me on M7 Win:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let control=Y;
options mprint symbolgen mlogic ;
data A
      %if &amp;amp;control = X %then %do;
     B ;
      %end;
      %else %do;
     C ;
      %end;
  X = 1;
run;
     
data A
       %if &amp;amp;control = X %then %do;
     B 
       %end;
       %else %do;
     C 
       %end;
     D  ;
  X = 1;
run;

data A
       %if &amp;amp;control = X %then %do;
     B 
       %end;
       %else %do;
     C 
       %end;
     ;
  X = 1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;LI-SPOILER&gt;
&lt;P&gt;25 %let control=Y;&lt;BR /&gt;26 options mprint symbolgen mlogic ;&lt;BR /&gt;27 data A&lt;BR /&gt;SYMBOLGEN: Macro variable CONTROL resolves to Y&lt;BR /&gt;28 %if &amp;amp;control = X %then %do;&lt;BR /&gt;29 B ;&lt;BR /&gt;30 %end;&lt;BR /&gt;31 %else %do;&lt;BR /&gt;32 C ;&lt;BR /&gt;33 %end;&lt;BR /&gt;34 X = 1;&lt;BR /&gt;35 run;&lt;/P&gt;
&lt;P&gt;NOTE: Compression was disabled for data set WORK.A because compression overhead would increase the size of the data set.&lt;BR /&gt;NOTE: Compression was disabled for data set WORK.C because compression overhead would increase the size of the data set.&lt;BR /&gt;NOTE: The data set WORK.A has 1 observations and 1 variables.&lt;BR /&gt;NOTE: The data set WORK.C has 1 observations and 1 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;36 &lt;BR /&gt;37 data A&lt;BR /&gt;SYMBOLGEN: Macro variable CONTROL resolves to Y&lt;BR /&gt;38 %if &amp;amp;control = X %then %do;&lt;BR /&gt;39 B&lt;BR /&gt;40 %end;&lt;BR /&gt;41 %else %do;&lt;BR /&gt;42 C&lt;BR /&gt;43 %end;&lt;BR /&gt;44 D ;&lt;BR /&gt;2 The SAS System 13:45 Thursday, November 25, 2021&lt;/P&gt;
&lt;P&gt;45 X = 1;&lt;BR /&gt;46 run;&lt;/P&gt;
&lt;P&gt;NOTE: Compression was disabled for data set WORK.A because compression overhead would increase the size of the data set.&lt;BR /&gt;NOTE: Compression was disabled for data set WORK.C because compression overhead would increase the size of the data set.&lt;BR /&gt;NOTE: Compression was disabled for data set WORK.D because compression overhead would increase the size of the data set.&lt;BR /&gt;NOTE: The data set WORK.A has 1 observations and 1 variables.&lt;BR /&gt;NOTE: The data set WORK.C has 1 observations and 1 variables.&lt;BR /&gt;NOTE: The data set WORK.D has 1 observations and 1 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.04 seconds&lt;/P&gt;
&lt;P&gt;47 &lt;BR /&gt;48 data A&lt;BR /&gt;SYMBOLGEN: Macro variable CONTROL resolves to Y&lt;BR /&gt;49 %if &amp;amp;control = X %then %do;&lt;BR /&gt;50 B&lt;BR /&gt;51 %end;&lt;BR /&gt;52 %else %do;&lt;BR /&gt;53 C&lt;BR /&gt;54 %end;&lt;BR /&gt;55 ;&lt;BR /&gt;56 X = 1;&lt;BR /&gt;57 run;&lt;/P&gt;
&lt;P&gt;NOTE: Compression was disabled for data set WORK.A because compression overhead would increase the size of the data set.&lt;BR /&gt;NOTE: Compression was disabled for data set WORK.C because compression overhead would increase the size of the data set.&lt;BR /&gt;NOTE: The data set WORK.A has 1 observations and 1 variables.&lt;BR /&gt;NOTE: The data set WORK.C has 1 observations and 1 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.01 seconds&lt;BR /&gt;cpu time 0.01 seconds&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/LI-SPOILER&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 00:55:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782388#M249400</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-11-25T00:55:08Z</dc:date>
    </item>
    <item>
      <title>Re: Funny quirk of open code %IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782405#M249413</link>
      <description>&lt;P&gt;Well, it's a workaround, but clearly not a solution. This is a bug and needs fixing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The fact that this was reported with M5 and is not yet fixed is somewhat disturbing. After all, we always tend to brag about SAS' software quality to beginners and outsiders.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Nov 2021 07:25:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782405#M249413</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-11-25T07:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Funny quirk of open code %IF</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782443#M249430</link>
      <description>&lt;P&gt;Kurt,&lt;/P&gt;
&lt;P&gt;I got no problem. Maybe it is sas version problem. Mine is stand-alone PC version SAS 9.4M7&amp;nbsp; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;NOTE: SAS initialization used:
      real time           1.76 seconds
      cpu time            1.35 seconds

1    %let control=Y;
2
3    data
4    %if &amp;amp;control = X
5    %then %do;
6      work.check
7    %end;
8    %else %do;
9      work.test
10   %end;
11   ;
12   x = 1;
13   run;

NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.05 seconds
      cpu time            0.01 seconds


14
15   data
16   %if &amp;amp;control = X
17   %then %do;
18     work.check
19   %end;
20   %if &amp;amp;control ne X
21   %then %do;
22     work.test
23   %end;
24   ;
25   x = 1;
26   run;

NOTE: The data set WORK.TEST has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds












&lt;/PRE&gt;</description>
      <pubDate>Thu, 25 Nov 2021 13:09:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Funny-quirk-of-open-code-IF/m-p/782443#M249430</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-11-25T13:09:31Z</dc:date>
    </item>
  </channel>
</rss>

