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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.
Ready to level-up your skills? Choose your own adventure.