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 (May 2011, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 10 May 2011 10:39:31 -0700
Reply-To:     "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: Need help to determine gap -- REVISED
In-Reply-To:  <201105101639.p4AAoUpA012692@willow.cc.uga.edu>
Content-Type: text/plain; charset=utf-8

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > Dave Brewer > Sent: Tuesday, May 10, 2011 9:40 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Need help to determine gap -- REVISED > > Hi Art, > > Thanks for your suggestion. > > I am trying to figure out how to code Toby's solution using your > solution. > > Dave > > On Tue, 10 May 2011 09:22:26 -0400, Arthur Tabachneck > <art297@ROGERS.COM> > wrote: > > >Dave, > > > >There is probably a more direct way of specifying the code, but I > think > that > >the following will accomplish what you want: > > > >data dave; > > input (jan1 feb1 mar1 apr1 may1 jun1 jul1 aug1 sep1 oct1 nov1 dec1 > > jan2 feb2 mar2 apr2 may2 jun2 jul2 aug2 sep2 oct2 nov2 dec2) > ($1.) > >; > > > > x=cats(of jan1--dec2); > > do while (x ne prxchange("s|00|0|", -1, x)); > > x=prxchange("s|00|0|", -1, x); > > end; > > if find (x, '11011')>0; > > cards; > >001101100000000000000000 > >110011000000000000000000 > >001100111000000000000000 > >000000111101100000000000 > >; > >run; > > > >HTH, > >Art > > > >P.S. If someone knows how to state the regular expression so that it > really > >does run iteratively on its own I'd appreciate learning the correct > way of > >coding it. > >-------

<<<snip>>>

Your first request could be done as follows :

data dave1; input (jan1 feb1 mar1 apr1 may1 jun1 jul1 aug1 sep1 oct1 nov1 dec1 jan2 feb2 mar2 apr2 may2 jun2 jul2 aug2 sep2 oct2 nov2 dec2) (1.); if _n_ EQ 1 then pattern = PRXparse('/1{2,}01{2,}/'); match_string = cats(of jan1--dec2); match_flag = PrxMatch(pattern,match_string); if match_flag; cards; 001101100000000000000000 110011000000000000000000 001100111000000000000000 000000111101100000000000 ; run;

For your current request, just add a '+' (meaning 1 or more) after the 0 in the pattern

data dave1; input (jan1 feb1 mar1 apr1 may1 jun1 jul1 aug1 sep1 oct1 nov1 dec1 jan2 feb2 mar2 apr2 may2 jun2 jul2 aug2 sep2 oct2 nov2 dec2) (1.); if _n_ EQ 1 then pattern = PRXparse('/1{2,}0+1{2,}/'); match_string = cats(of jan1--dec2); match_flag = PrxMatch(pattern,match_string); if match_flag; cards; 001101100000000000000000 110011000000000000000000 001100111000000000000000 000000111101100000000000 ; run;

hope this is helpful,

Dan

Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204


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