Hi there,
I have code the below logic to search the multiple words from the comments variable(CMMT_X) but its not working properly.
DATA TEST;
SET X (obs= 20);
Comments= upcase (CMMT_X);
X= INDEX(CMMT_X, "DECLINE IN PROPERTY");
/*x1= spedis(CMMT_X, "DECLINE IN PROPERTY");*/
got_value=SCAN(CMMT_X, "DECLINE","PROPERTY");
/**/
/* if index(CMMT_X,'DECLINE IN PROPERTY') or index(CMMT_X,'Decrease in Market Value')then RL_Group= 'Decrease to Security Value'; */
/* else if index(CMMT_X,'Customer Complaint') or index(CMMT_X,'Complaint') then RL_Group= 'Customer Complaint' ;*/
/* else if index(CMMT_X,'Customer Complaint') or index(CMMT_X,'Complaint') then RL_Group= 'Customer Complaint' ;*/
if prxmatch("m/DECLINE IN PROPERTY|Decrease in Market Value|Security Value|security property|Property damaged|Property deteriorated|Valuer Error/oi",CMMT_X) > 0 then found='Decrease to Security Value';
else if prxmatch("m/Customer Complaint|'Complaint/oi",CMMT_X) > 0 then found='Customer Complaint';
else if prxmatch("m/Fraud/oi",CMMT_X) > 0 then found='Fraud'; /* Fraud Internal / Fraud External */
else if prxmatch("m/LMI Claim due|No LMI| Delays with MIP|Non-Fair Wear and Tear / oi",CMMT_X) > 0 then found='LMI Claim Reduction';
else if prxmatch("m/Project Jefferson | Project Storm / oi",CMMT_X) > 0 then found='Project Jefferson';
else if prxmatch("m/Project Alton/ oi",CMMT_X) > 0 then found='Project Alton';
else if prxmatch("m/Process Error|Error / oi",CMMT_X) > 0 then found='Process Error';
/*|Funds credited to incorrect account|LMI maladministration|LMI Premium not paid|Release of security for nil consideration|Lender error - LVR miscalculation|Credit Officer - LVR miscalculation | Other HL funding issue | VLOC Limit not Cancelled |Lender Error - Unacceptable Security | LMI Missing documentation |Credit Officer - unacceptable security|Lender Committed | Loan not Secured at Origination |Missing security documentation |Construction Loan Progress Payments|VLOC Limit not Reduced |Lender error - missing documentation|Lender Error - Maladministration |Credit Officer - Approved Outside Policy/Poor Credit Decision | Poor Credit Maladministration |Lender Error - Maladministration |Missing security documentation | VLOC Limit not Cancelled | Other HL funding issue | Other LMI issue */
else if prxmatch("m/Provision Raised in Error|Provision Raised Error|LMI Claim should be lodged |Provision not required|LMI Claim should be lodged / oi",CMMT_X) > 0 then found='Provision Raised in Error';
else if prxmatch("m/Incomplete Building Loan|Builder/ oi",CMMT_X) > 0 then found='Incomplete Building Loan';
else if prxmatch("m/Uninsured Property|No building insurance|Fire Damage/ oi",CMMT_X) > 0 then found='Uninsured Property';
else if prxmatch("m/Valuation Procedures|Non-System Ordered Valuation|Incorrect Source Document | Incorrect Source Valuation |Incorrect Source|VAS decision not followed|Incorrect VAS input / oi",CMMT_X) > 0 then found='Valuation Procedures';
else found='Miscellaneous';
run;
Is there any other better way to write.Instead of prxmatch is index better?
Appreciate your help.thanks
Regards
1. its not working properly.
How?
2. Is there any other better way to write.Instead of prxmatch is index better?
Index() or find() would be much faster. Find() allows for case-insensitive matches, index() doesn't.
3.You seem to have typos in your values:
"m/Customer Complaint|'Complaint/oi" Do you want to test for the single quote?
"m/Project Jefferson | Project Storm / oi" Do you want to test for the space?
4. You are not using the scan function properly.
Thanks Chris..
The code is working, there is no issue with quotation marks..only problem is it is not checking all the similar words that i am looking on the each groupings...below example..
if prxmatch("m/Provision Raised in Error|Provision Raised Error|LMI Claim should be lodged |Provision not required|LMI Claim should be lodged / oi",CMMT_X) > 0 then found='Provision Raised in Error'
Looks only for one word not working for multiple word search...
I did use Index but that not giving 100% result too..
So thought is any other better way to search multiple words in SAS?
My mentioning the quote and space is not about the code not running, it's about your match being impaired.
I have no clue what you are trying to match. Only you know.
Something like this gives more flexibility:
prxmatch("m/Provision.*Error|Claim.*(not|should).*lodged|Provision.*required/oi",CMMT_X)
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.