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 (August 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 30 Aug 2007 20:00:24 +0200
Reply-To:   Rune Runnestø <rune@FASTLANE.NO>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Rune Runnestø <rune@FASTLANE.NO>
Subject:   Re: regex challenge
Comments:   To: sas-l@uga.edu

It seems that I have not been precise enough when defining the criteria. I want to pick up records where STRING starts with '00' or '01'. '10' as a start is not meeting my criteria. The rest of STRING, from sign # 3 and further, must not contain only '0'.

Rune

"Guido T" <cymraegerict@GMAIL.COM> wrote in message news:46638d360708300723l60aee7d6w7f57efd6b33b2ab2@mail.gmail.com... > Hi Rune, > > Well ... > > if not verify(string,'0') then output myds1; > else if string eq: '0' and compress(substr(string,2),'0') ne ' ' then > output myds2; > > Would give the output using your test data, but that isn't what you say in > the text > > one of the first two signs shall be a '0' > > so 10100000000 would be valid. > > Regards > ++ Guido > > On 30/08/2007, Rune Runnest=F8 <rune@fastlane.no> wrote: >> >> So far noone has solved the problem to create MYDS2 correctly. >> >> Manuel suggested: >> >> data myds2; >> if _n_ =3D 1 then re =3D prxparse('/^([1-9]\d|\d[1-9]).*[1-9]/'); >> retain re; >> input string $char11.; >> if prxmatch(re, string) gt 0 then ok=3D1; else ok=3D0; >> datalines; >> 00000000000 >> 12345678912 >> 01000000000 >> 10000000000 >> 11000000000 >> 00100000000 >> 01100000000 >> 10100000000 >> 11100000000 >> 00000000010 >> 01000000010 >> 10000000010 >> 11000000010 >> 10000000001 >> run; >> >> This can be rewritten like this: >> >> data myds2_ok myds2_notok; >> if _n_ =3D 1 then re =3D prxparse('/^([1-9]\d|\d[1-9]).*[1-9]/'); >> retain re; >> input string $char11.; >> if prxmatch(re, string) gt 0 then do; >> ok=3D1; >> output myds2_notok; >> end; >> else do; >> ok=3D0; >> output myds2_ok; >> end; >> datalines; >> 00000000000 >> 12345678912 >> 01000000000 >> 10000000000 >> 11000000000 >> 00100000000 >> 01100000000 >> 10100000000 >> 11100000000 >> 00000000010 >> 01000000010 >> 10000000010 >> 11000000010 >> 10000000001 >> run; >> >> Neither MYDS2_OK nor MYDS2_NOTOK is right. The values I want to pick >> up, are these: >> 01000000000 >> 00100000000 >> 01100000000 >> 00000000010 >> 01000000010 >> >> >> Only these values satisfy the criteria, which is that one of the first >> two signs shall be a '0'. AND the rest of the string shall NOT ONLY >> contain zeros. >> >> Rune >>


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