BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Smijoss
Fluorite | Level 6

Hi All,

I am trying to execute the following code.  It works fine when I change the  "not ="   to  an "='"  Sign.  But I do not understand why not = is not working.

%MACRO  Combine_and_Transpose(REG);

  %if %eval( "&Reg."  not = "ALL")  %then

  %let Group_vars = %STR(ACCOUNT_NAME);

  %Else %let Group_vars = %STR(REGION PU9 GROUP_NAME ACCOUNT_NAME INSUTYPE);

%Mend;

%Combine_and_Transpose(&REG.);

Run;

Error Message -

ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:

       "MAS"  not = "ALL"

ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.

ERROR: The macro COMBINE_AND_TRANSPOSE will stop executing.

1 ACCEPTED SOLUTION

Accepted Solutions
Linlin
Lapis Lazuli | Level 10
5 REPLIES 5
Linlin
Lapis Lazuli | Level 10

try using "ne".

Smijoss
Fluorite | Level 6

Thanks a lot ...   i like the NE  compared to  ^=   :smileygrin:  but both shud work i believe. ..

Wish sas had used the <> symbol Smiley Happy

Tom
Super User Tom
Super User

SAS does use the <> operator but it is NOT the same as the NE operator. 

In base SAS and IML it means take the maximum value. 

So result of 0 <> -3 is 0 .

SAS(R) 9.2 Language Reference: Concepts, Second Edition

Tom
Super User Tom
Super User

Just put the NOT outside the comparison. Also %EVAL() is not needed.

Instead of %if %eval( "&Reg."  not = "ALL")  %then

use %if not ( "&Reg."  = "ALL")  %then

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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