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-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
  • 5 replies
  • 4308 views
  • 0 likes
  • 4 in conversation