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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 4376 views
  • 0 likes
  • 4 in conversation