BookmarkSubscribeRSS Feed
rebeccas
Calcite | Level 5

Why does this code not work? It doesn't seem to like the multiple conditions inside the if statement?

 

%if &WATERFALL_RUN. = N and &SENSITIVITY_RUN. = N %then %do

%process_flow_ALL;

%end;

 

4 REPLIES 4
gamotte
Rhodochrosite | Level 12

Hello,

 

What do you mean by 'does not work' ?

Are there error messages in the log ?

There is nothing wrong with this code.

Use mprint, mlogic and symbolgen options to check how the macro code is resolved.

 

 

PeterClemmensen
Tourmaline | Level 20

What does your log say?

Kurt_Bremser
Super User

It all depends on the contents of the macro variables.

%macro testmac;
%let waterfall_run=N;
%let sensitivity_run=N;
%if &WATERFALL_RUN. = N and &SENSITIVITY_RUN. = N %then %do; 
%put it works!;
%end;
%mend;

%testmac

Log from this:

24         %macro testmac;
25         %let waterfall_run=N;
26         %let sensitivity_run=N;
27         %if &WATERFALL_RUN. = N and &SENSITIVITY_RUN. = N %then %do;
28         %put it works!;
29         %end;
30         %mend;
31         
32         %testmac
it works!
ballardw
Super User

Doesn't work is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 737 views
  • 0 likes
  • 5 in conversation