BookmarkSubscribeRSS Feed
DRamsey
Calcite | Level 5
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!
3 REPLIES 3
Russ_SAS
SAS Employee
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
DRamsey
Calcite | Level 5
Thank you Russ.
deleted_user
Not applicable
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?(!)

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
  • 3 replies
  • 13223 views
  • 0 likes
  • 3 in conversation