The SAS Output Delivery System and reporting techniques

EQ and NE in IF expressions

Reply
New Contributor
Posts: 2

EQ and NE in IF expressions

Sorry if this is in the wrong forum, but I couldn't figure out where exactly this should go.

I'm looking at another person's code, and in several places they appear to be confirming the existence of a variable using expressions like the following (within a macro):

%If &var eq %then ...

-OR-

%If &var ne %then ...

What's throwing me off is the interpretation of how the expression is evaluated.

My assumption was that in the first expression, if the variable is not missing then the expression is true and the "then" will execute. In the second example, if the variable is missing, then the expression is true and the "then" will also execute.

Is this correct, or is this backwards?

Thanks!
SAS Employee
Posts: 9

Re: EQ and NE in IF expressions

A good place to send this type of question would be to support@sas.com

This will open a track for you with SAS Technical Support. I went ahead and opened a track for you and the number is us6378828.

We do not currently have a macro forum, the forum you have sent this question to is mainly for ODS, PRINT, REPORT and TABULATE.

But to answer your question:

The statement %If &var eq %then is checking to see if the macro variable var contains a null value.

The statement %If &var ne %then is checking to see if the macro variable var is not equal to a null value.

If you have any further questions regarding this issue please send e-mail to support@sas.com with us6378828 as the subject and I will be happy to assist you.

Thanks, Russ Tyndall
New Contributor
Posts: 2

Re: EQ and NE in IF expressions

Thank you Russ.
N/A
Posts: 0

Re: EQ and NE in IF expressions

Russ,
as with quite a few other posts here, there is a suggestion that another group should be opened. I have forwarded to the suggested SAS help center (nothing yet), so I will continue to ask for another group which will handle all these off-topic issues (suggestion of ETL or General SAS Base?).
Jon

And while I'm here could you add word SAS to the spell check dictionary?(!)
Ask a Question
Discussion stats
  • 3 replies
  • 1398 views
  • 0 likes
  • 3 in conversation