Find function is giving unexpected results.
Output:
I am expecting 1 as the answer here but getting 0.
In text format output for last three fields:
full_rating: "Action: New Rating (Mar-07-2018)
From ""-"" to ""BB-"""
b_rating: "Action: New Rating (Mar-07-2018)
From ""-"" to ""BB-"""
find: 0
Code:
proc sql; create table old_match_change as select *, find(compress(upcase(full_rating),' ():"'), compress(upcase(b_rating),' ():"')) as find from old_match where find(compress(upcase(full_rating),' ():"'), compress(upcase(b_rating),' ():"'))=0; quit;
If you want to get rid of the line breaks, use 'c' (remove control characters) as the third parameter to COMPRESS, e.g.:
proc sql;
create table old_match_change as
select *, find(compress(upcase(full_rating),' ():"','c'), compress(upcase(b_rating),' ():"','c')) as find
from old_match
where find(compress(upcase(full_rating),' ():"','c'), compress(upcase(b_rating),' ():"','c'))=0;
quit;
You seem to have a line break. Compress non-printable characters too a lines breaks can take different forms.
The compress function allows you to eliminate non-printable characters. See the documentation.
Note also that the find function allows case insensitive comparisons, so you needn't use the upcase function here. Again see the documentation.
Compare the lengths of the compressed strings. If they are the same, compare their value printed with the $hex. format.
If you want to get rid of the line breaks, use 'c' (remove control characters) as the third parameter to COMPRESS, e.g.:
proc sql;
create table old_match_change as
select *, find(compress(upcase(full_rating),' ():"','c'), compress(upcase(b_rating),' ():"','c')) as find
from old_match
where find(compress(upcase(full_rating),' ():"','c'), compress(upcase(b_rating),' ():"','c'))=0;
quit;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.