LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2005, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 6 Jul 2005 07:54:52 +0000
Reply-To:     Guido T <cymraeg_erict@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Guido T <cymraeg_erict@HOTMAIL.COM>
Subject:      Re: delete duplicate string within a single variable
In-Reply-To:  <BAY101-F380DE4951758C6A968170ADED90@phx.gbl>
Content-Type: text/plain; format=flowed

I was a bit too quick with my initial "solution". The middle compress isn't needed, compressing out extra spaces isn't a problem. Also TRANSLATE only needs a single space to translate to. How many years have I been using TRANSLATE function? Sigh...

What it does is compress out of the _DIGITS string (containing the valid character, in the correct order) the characters from *A* that aren't in the _DIGITS string.

++ Guido

295 data test(drop=_digits); 296 set xx; 297 retain _digits '0123456789'; 298 x = compress(_digits,translate(_digits,' ',a)); 299 put a= x=; 300 run;

a=000000000 x=0 a=000110102 x=012 a=420333000 x=0234 a=9800019800001987 x=01789 a=9a8a7a6vvvvvvv0000 x=06789

NOTE: There were 5 observations read from the data set WORK.XX. NOTE: The data set WORK.TEST has 5 observations and 3 variables. NOTE: DATA statement used: real time 0.01 seconds cpu time 0.01 seconds


Back to: Top of message | Previous page | Main SAS-L page