Dear all,
I am trying to use the use the find() function in SAS Enterprise 5.1.
It does not work as specified in all the literature I found on the web. It is only able to find perfect matches between two
strings. For instance, it return 1 on find(col1,col2) when col1 contains "CORK" and col2 "CORK", but 0 when col1 contains
"ICORK" and col2 contains "CORK".
Can someone explain why find() has the behavior ?
Thanks,
Thierry
Hello,
Providing the substring (in your ex. col2) in the form of a variable means SAS adds the spaces which fill in the variable until thje length provided (in your example 20).
Adjusting the code to test = find(col1,trim(col2)); will do it .
Hello,
It works as explained in the documentation:
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002267763.htm
The following example returns z=2 in the log.
data _null_;
col1='ICORK';
col2='CORK';
z=find(col1,col2);
put z=;
run;
Here is my test code:
data testFile;
length col1 $20 col2 $20;
input col1 $ col2 $;
datalines;
ICORK CORK
CORK DUBLIN
;
run;
data testFind;
set testFile;
put col1= col2=;
test = find(col1,col2);
run;
and is find() does not find CORK in ICORK
Do you have an idea why?
Thansks,
Thierry
Hello,
Providing the substring (in your ex. col2) in the form of a variable means SAS adds the spaces which fill in the variable until thje length provided (in your example 20).
Adjusting the code to test = find(col1,trim(col2)); will do it .
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 save with the early bird rate—just $795!
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.