DATA Step, Macro, Functions and more

what does 'ne' mean in this context?

Reply
New Contributor
Posts: 2

what does 'ne' mean in this context?

Hi, basic question.

I understand this:

%if &city ne 'New York' %then %do;

     * do stuff here

%end;

but not this:

%if &city ne %then %do;

     * do stuff here

%end;

What does the 'ne' mean in the second statement?  Is it comparing &city ne to...what exactly?

Thanks

Super User
Posts: 10,483

Re: what does 'ne' mean in this context?

Some one may be trying to get if the city is not blank.

New Contributor
Posts: 2

Re: what does 'ne' mean in this context?

That seems to be the case.  So is &city ne  equivalent to:  &city ne .  ?

Thanks

Occasional Contributor
Posts: 14

Re: what does 'ne' mean in this context?

Nope.  The &city ne . would be true whenever the macro variable does not resolve to exactly = .

The &city ne would be true whenever the macro variable does not resolve to exactly =             (nothing at all).

Keep in mind that macro variables are literal text strings, so when it checks for ne and nothing after, it is literally checking for nothing in the string.

Occasional Contributor
Posts: 14

Re: what does 'ne' mean in this context?

I think it compares it to a missing value for the macro variable.

So when I %let city = something,

it triggers that '&city ne is true'.

But when

%let city=;

You get '&city ne is false'.

So it must test against an empty macro variable by default.

Kind of a cool behavior, I only learned it from experimenting with your code.

Respected Advisor
Posts: 3,777

Re: what does 'ne' mean in this context?

NE is the comparision operator and it means NOT EQUAL.  In both expressions.

Contributor
Posts: 45

Re: what does 'ne' mean in this context?

I like to use

%if &city ne %str() %then %do;

instead of leaving a blank space...just because it is more obvious to me

Ask a Question
Discussion stats
  • 6 replies
  • 2694 views
  • 1 like
  • 5 in conversation