Date: Thu, 9 Aug 2007 18:22:51 -0400
Reply-To: sas_andy@BOOSECAT.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Andy Andrews <sas_andy@BOOSECAT.COM>
Subject: Removing words from a string
Content-Type: text/plain; charset=UTF-8
Hi all...you helped out so much earlier I thought I'd throw another bone in! I have 2 macro variables - good and bad. I need to remove all instances of the words in bad from good.
For example:
%let good=blue white red yellow orange purple black;
%let bad=yellow purple;
I need to remove "yellow" and "purple" from the macro variable good. I'm currently breaking apart the variables word by word, then merging them back in where it's in good and not in bad. This works great, however the code is a little long and ugly. It doesn't matter how the data ends back up. It can be a single-variable dataset (currently what I have), another macro variable, etc.
Thanks! I hope this makes sense to someone!
|