I am trying to use modifiers on the compget function. Here's my code:
data compged;
set crossjoin;
match=compged(Dog_Nm1, Dog_Nm2,30,"l:i");
run;
This returns an error. Does anyone know how I use these modifiers? (30, l:i)
I also noticed that "Pippy Boy" and Pippy" give a value greater than 0 in the code above, but when I do this:
Data _Null_ ;
Text1 = "Pippy" ;
Text2 = "Pippy Boy" ;
Test = CompGed( Text2 , Text1 ,"il:") ;
Put Test= ;
Run ;
it returns a value of 0. What?!
Place the modifiers inside quotes to indicate they are literal values. Without quotes then SAS expects the modifiers to be in a variable and the : is getting treated as some sort of operator in the wrong place:
match=compged(Dog_Nm1, Dog_Nm2,30,'l:i');
Yup, I modified the question when I figured that out. The error is gone, but the problem is still there. I can't get "Pippy Boy" and "Pippy" to match using the colon modifier in the data step, so I'm not sure that it is working correctly even though it IS working in the test code.
@theponcer wrote:
Yup, I modified the question when I figured that out. The error is gone, but the problem is still there. I can't get "Pippy Boy" and "Pippy" to match using the colon modifier in the data step, so I'm not sure that it is working correctly even though it IS working in the test code.
Your code when I run it gets a value of 0, which is a perfect match for compged.
If your actual values looks like and is not returning 0 then perhaps you have a leading character other than a space character such as a null character, ASCII 255. Which returns 300. I can't post code as the forum changes the NULL to a space but in this code:
Data _Null_ ; Text1 = "Pippy" ; Text2 = " Pippy Boy" ; Test = CompGed( Text2 , Text1 ,"il:") ; Put Test= ; Run ;
highlight the space before Pippy in Text2. Then hold the Alt key and type 255 on the number pad (on a Windows system) and release. Then run the code to see 300 as a result
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.