05-07-2013 04:12 AM
Imagine that you have a folder with the following reports:
Commissions GW 0413 Ohio
Commissions GW 0413 Indiana
Commissions GW 0413 Minnesota
Commissions GW 0413 Illinois
Commissions GW 0413 Pennsylvania
Commissions GW 0413 Colorado
You want SAS to read the file names starting from "GW", and you want to turn the spaces into underscores. So, when read into SAS, the strings should look like this:
I think this can be done by means of the SCAN function, but I can't seem to make it work. I'd appreciate any advice.
Thanks for your time.
05-07-2013 07:27 AM
Maybe this could work:
new_string = translate(trim(prxchange("s/.*Commissions //", -1, string)), "_", "");
prxchange : will replace/change everything up to (including) the word Commissions with a blank space;
trim : will remove the trailing blanks (so you don't attach an underscore at the end of the string;
translate : will replace any blanks with underscore.