Hello,
In a company name standardisation process, I expect to 'Convert “AND”, “ET”, “Y”, “UND” and so on, to “&”. and Remove all other punctuation.'
So, I would like to do it by following steps,
1. split a variable into several independent variables.
2. Convert “AND”, “ET”, “Y”, “UND” and so on, to “&”.
3. Remove all other punctuation.
4. merge them together ( both keep the original variable and new variable).
5. create a new variable to remind me of what the change happen (i.e., 'convert to &', 'remove punctuation' or 'both')
Could you please give me some suggestion about this?
Thanks for your attention to this matter.
Can you please post a sample data of what you HAVE and WANT?
@Alexxxxxxx wrote:
Hello,
In a company name standardisation process, I expect to 'Convert “AND”, “ET”, “Y”, “UND” and so on, to “&”. and Remove all other punctuation.'
So, I would like to do it by following steps,
1. split a variable into several independent variables.
2. Convert “AND”, “ET”, “Y”, “UND” and so on, to “&”.
3. Remove all other punctuation.
4. merge them together ( both keep the original variable and new variable).
5. create a new variable to remind me of what the change happen (i.e., 'convert to &', 'remove punctuation' or 'both')
Could you please give me some suggestion about this?
Thanks for your attention to this matter.
1. SCAN(), SUBSTR() or PRX()
2. TRANWRD()
3. COMPRESS()
4. CATT()
5. No idea.
Check character functions here:
Use prxChange:
data _null_;
length text newText $64;
do text = "Procter and Gamble", "Greyhound Lines", "Moët et Chandon";
newText = prxChange("s/\b(AND|ET|Y|UND)\b/&/io", -1, text);
put (_all_) (=);
end;
run;
text=Procter and Gamble newText=Procter & Gamble text=Greyhound Lines newText=Greyhound Lines text=Moët et Chandon newText=Moët & Chandon
Compare text and newText to detect any change.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.