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:
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')
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')
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.
Maxim 2: read the log
A problem is clearly indicated. Fix that and your code will probably work.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
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.
Ready to level-up your skills? Choose your own adventure.