SUPPORT / SAMPLES & SAS NOTES
 

Support

Problem Note 67972: An %IF statement in open code can insert additional semicolons in the code after the code is resolved

DetailsHotfixAboutRate It

An %IF statement in open code inserts additional semicolons into submitted code after resolution when the following conditions are met:

  • An %ELSE branch is specified with the %IF test.
  • The %IF test resolves to FALSE, making the code take the %ELSE branch.

The behavior can be illustrated after you submit the following sample macro:

%macro test(var);
   data _null_;   
   put "&VAR";
   run;
%mend;

When the macro is called in open code and its input parameter (VAR) contains an %IF test that resolves to TRUE, the correct results are generated, as shown in the SAS® log here:

%test(%IF 1 %THEN %DO; 123 %END;%ELSE %DO; 456 %END;)

MLOGIC(TEST):  Beginning execution.
MLOGIC(TEST):  Parameter VAR has value 123
MPRINT(TEST):   data _null_;
SYMBOLGEN:  Macro variable VAR resolves to 123
MPRINT(TEST):   put "123";
MPRINT(TEST):   run; 
123
NOTE: DATA statement used (Total process time):

However, if you submit the macro with an %IF test that resolves to FALSE, additional semicolons are generated in the code:

%test(%IF 0 %THEN %DO; 123 %END;%ELSE %DO; 456 %END;)

MLOGIC(TEST):  Beginning execution.
MLOGIC(TEST):  Parameter VAR has value ; 456;
MPRINT(TEST):   data _null_;
SYMBOLGEN:  Macro variable VAR resolves to ; 456;
MPRINT(TEST):   put "; 456;";
MPRINT(TEST):   run;

; 456;
NOTE: DATA statement used (Total process time):

A workaround is to modify the logic of the code so that the %ELSE branch is not used. A further code modification is to not use an %IF statement in open code.

Click the Hot Fix tab in this note to access the hot fix for this issue.



Operating System and Release Information

Product FamilyProductSystemProduct ReleaseSAS Release
ReportedFixed*ReportedFixed*
SAS SystemBase SASz/OS9.49.4_M89.4 TS1M09.4 TS1M8
z/OS 64-bit9.49.4_M89.4 TS1M09.4 TS1M8
Microsoft® Windows® for x649.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows 8 Enterprise x649.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows 8 Pro x649.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows 8.1 Enterprise 32-bit9.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows 8.1 Enterprise x649.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows 8.1 Pro 32-bit9.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows 8.1 Pro x649.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows 109.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows Server 2008 R29.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows Server 2008 for x649.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows Server 2012 Datacenter9.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows Server 2012 R2 Datacenter9.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows Server 2012 R2 Std9.49.4_M89.4 TS1M09.4 TS1M8
Microsoft Windows Server 2012 Std9.49.4_M89.4 TS1M09.4 TS1M8
Windows 7 Enterprise x649.49.4_M89.4 TS1M09.4 TS1M8
Windows 7 Professional x649.49.4_M89.4 TS1M09.4 TS1M8
64-bit Enabled AIX9.49.4_M89.4 TS1M09.4 TS1M8
64-bit Enabled Solaris9.49.4_M89.4 TS1M09.4 TS1M8
HP-UX IPF9.49.4_M89.4 TS1M09.4 TS1M8
Linux for x649.49.4_M89.4 TS1M09.4 TS1M8
Solaris for x649.49.4_M89.4 TS1M09.4 TS1M8
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.