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 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 17 Jul 2008 08:25:40 -0700
Reply-To:     karma <dorjetarap@GOOGLEMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         karma <dorjetarap@GOOGLEMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: how to remove characters from observations when found at a
              specific place?
Comments: To: sas-l@uga.edu
Content-Type: text/plain; charset=ISO-8859-1

On 17 Jul, 13:34, Patrick <patrick.mat...@gmx.ch> wrote: > That sounds like a case for "regular expressions" to me. > > The function PRXCHANGE should do the job:http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a002601591.htm > > Have a look athttp://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a002288677.htm > in case that you haven't used regular expressions before. It needs a > bit of effort to understand how it works - but it's worth the time! > > Cheers > > Patrick

I found this a bit tricky to carry out with RegExp. You could use something like the following, in this example leading 'S' ,'/' and 'L' s are being removed:

data have; input val $1-14; cards; /adgag/adgas/ LadgasgLfdaL SdadfdSdsfasL dagdagSadsfS Ladsfasdfdf ; run;

data want(drop=_:); set have; _len = length(val); _start = val in:('/' 'L' 'S'); _end = reverse(strip(val)) in: ('/' 'L' 'S'); val = substr(val, _start+1, _len-(_start + _end)); run;

proc print;run;

1 adgag/adgas 2 adgasgLfda 3 dadfdSdsfas 4 dagdagSadsf 5 adsfasdfdf


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