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 (February 2009, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 4 Feb 2009 15:43:30 -0500
Reply-To:     msz03@albany.edu
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Mike Zdeb <msz03@ALBANY.EDU>
Subject:      Re: Find position of last occurrence of character in a string
Content-Type: text/plain;charset=iso-8859-1

hi ... if a string can end with '//' , you need LOCB, otherwise LOCA is OK

data test; input string $30.; datalines; abc/abc/abc/333 xyz/999 rty//uu abcdefg// qqq ; run;

data test; set test; loca = length(string) - length(scan(string,-1,'/')); locb = length(catt(string,'*')) - length(scan(catt(string,'*'),-1,'/')); run;

proc print data=test; run;

-- Mike Zdeb U@Albany School of Public Health One University Place Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

> JDB, > > You could always use the REVERSE function on the string first, then the > INDEX function. > > > > > > Jack Clark > Senior Research Analyst > phone: 410-455-6256 > fax: 410-455-6850 > jclark@hilltop.umbc.edu > > University of Maryland, Baltimore County > Sondheim Hall, 3rd Floor > 1000 Hilltop Circle > Baltimore, MD 21250 > > > > > Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) > named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action > taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this > information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of JDB > Sent: Wednesday, February 04, 2009 2:59 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Find position of last occurrence of character in a string > > I am looking for a function that will allow me to find the position of > the last occurrence of a specific character in a string. Basically > the opposite of the index function. For example if I wanted to find > the position of the last "/" in the following string "abc/abc/abc/ > 333". I will not know how many "/" will appear before the last > occurrence. > > Thanks > >


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