BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
yliu1234
Obsidian | Level 7
data;
Business_Type = 'COMPANY';
party_type = 'individual';
if (Business_Type <> 'INDIVIDUAL' and party_type = 'individual')
then do;
party_type_FLAG="put "||COMPRESS(lowcase(Business_Type))||" as "||COMPRESS(party_type);
end;
else do; party_type_FLAG = 'match'; end;
run;

I expect this result, since the IF should return TRUE

 

Business_Type party_type party_type_FLAG
COMPANY individual put company as individual

 

 

However I got this result: 

yliu1234_0-1632343523260.png

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

Your syntax <> deceived you-

333 if (Business_Type <> 'INDIVIDUAL' and party_type = 'individual')
NOTE: The "<>" operator is interpreted as "MAX".

Log:


329
330  data;
331  Business_Type = 'COMPANY';
332  party_type = 'individual';
333  if (Business_Type <> 'INDIVIDUAL' and party_type = 'individual')
NOTE: The "<>" operator is interpreted as "MAX".
334  then do;
335  party_type_FLAG="put "||COMPRESS(lowcase(Business_Type))||" as "||COMPRESS(party_type);
336  end;
337  else do; party_type_FLAG = 'match'; end;
338  run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      333:19
NOTE: Invalid numeric data, 'INDIVIDUAL' , at line 333 column 19.
WARNING: Limit set by ERRORS= option reached.  Further errors of this type will not be printed.
Business_Type=COMPANY party_type=individual party_type_FLAG=match _ERROR_=1 _N_=1
NOTE: The data set WORK.DATA3 has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds

Try:

if (Business_Type ne 'INDIVIDUAL' and party_type = 'individual')

View solution in original post

6 REPLIES 6
novinosrin
Tourmaline | Level 20

Your syntax <> deceived you-

333 if (Business_Type <> 'INDIVIDUAL' and party_type = 'individual')
NOTE: The "<>" operator is interpreted as "MAX".

Log:


329
330  data;
331  Business_Type = 'COMPANY';
332  party_type = 'individual';
333  if (Business_Type <> 'INDIVIDUAL' and party_type = 'individual')
NOTE: The "<>" operator is interpreted as "MAX".
334  then do;
335  party_type_FLAG="put "||COMPRESS(lowcase(Business_Type))||" as "||COMPRESS(party_type);
336  end;
337  else do; party_type_FLAG = 'match'; end;
338  run;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      333:19
NOTE: Invalid numeric data, 'INDIVIDUAL' , at line 333 column 19.
WARNING: Limit set by ERRORS= option reached.  Further errors of this type will not be printed.
Business_Type=COMPANY party_type=individual party_type_FLAG=match _ERROR_=1 _N_=1
NOTE: The data set WORK.DATA3 has 1 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds

Try:

if (Business_Type ne 'INDIVIDUAL' and party_type = 'individual')

yliu1234
Obsidian | Level 7
Have used to only read the log line that has errors. Glad to learn this new skill to read the log deeply.
Astounding
PROC Star

What are you imagining the <> comparison means?

 

In an IF statement in a DATA step, it's the MAX operator.  In PROC SQL, it's "not equal".  

 

Just spell out the comparison that you want.

yliu1234
Obsidian | Level 7
Thank you. I wrote a lot of proc sql, too confidence of these operator, never think about it.
PaigeMiller
Diamond | Level 26

Maxim 2: read the log

 

A problem is clearly indicated. Fix that and your code will probably work.

--
Paige Miller
yliu1234
Obsidian | Level 7
Thanks!

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 6 replies
  • 1458 views
  • 4 likes
  • 4 in conversation