SAS users,
I would like to replace company type chracters such as LTD, limited, ltd. etc
So far I have done:
data test3;
set test2;
ocp=prxchange("s/([Pp][Tt][Yy] [Ll][Tt][Dd])|([Ll]imite
*if _n_=68;
run;
At the moment, I cannot deal with the ones that ends with a ".". How would you modify the above regular expression paraemter
so that it can perform prxchange for values such as:
ABC Pty. Ltd. => ABC
ABC Pty. Ltd. => ABC
Also, is there something to ensure that this string replace is done from the right end of each string?
Many thanks.
You may also use "i" option to make search case insensitive.
data x;
length original_credit_provider $32;
input original_credit_provider $1-32;
ocp=prxchange("s/PTY\.? (Limited|Ltd\.?)//i", -1, original_credit_provider);
datalines;
ABC Pty. Ltd.
ABC Pty. Limited
ABC Pty Limited
ABC Pty Ltd.
;
run;
How about it.
data test2; input original_credit_provider & $20.; cards; ABC Pty. Ltd. ABC Pty. Ltd. ; run; data test3; set test2; ocp=prxchange("s/([Pp][Tt][Yy]\.? [Ll][Tt][Dd]\.?)|([Ll]imite)|([Ll]t )|([Pp]t )|([Pp][Tt][Yy] [Ll]imite ) / /", -1, original_credit_provider); run;
Ksharp
Message was edited by: xia keshan
You may also use "i" option to make search case insensitive.
data x;
length original_credit_provider $32;
input original_credit_provider $1-32;
ocp=prxchange("s/PTY\.? (Limited|Ltd\.?)//i", -1, original_credit_provider);
datalines;
ABC Pty. Ltd.
ABC Pty. Limited
ABC Pty Limited
ABC Pty Ltd.
;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.