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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.