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 2012, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 10 Feb 2012 18:06:42 +0000
Reply-To:   "Zdeb, Michael S" <mzdeb@ALBANY.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   "Zdeb, Michael S" <mzdeb@ALBANY.EDU>
Subject:   Re: Any easier way?
Comments:   To: toby dunn <tobydunn@hotmail.com>
In-Reply-To:   <BLU152-W524BA6BCB73BA6F1EB09AEDE780@phx.gbl>
Content-Type:   text/plain; charset="Windows-1252"

hi ... thanks, still learning about PRX and your postings are a great way to learn more

back to the orginal posting, it looks as if this ...

data a; set a1(where=(dx1 in:('c1','c2','c3'...'c9') or dx2 in: 'c1','c2','c3'...'c9') or ... dx6 in:('c1','c2','c3'...'c9'))) a2(where=(dx1 in:('c1','c2','c3'...'c9') or dx2 in: ('c1','c2','c3'...'c9') or ... dx6 in:('c1','c2','c3'...'c9'))) ... a5(where=(dx1 in:('c1','c2','c3'...'c9') or dx2 in: ('c1','c2','c3'...'c9') or ... dx6 in:('c1','c2','c3'...'c9'))); run;

can be done with ...

data a;

set a1-a5;

where PrxMatch( '/c[1-9](?:,|$)/o' , Strip( CatX( ',' , DX1,DX2,DX3,DX4,DX5,DX6 ) ) );

run;

one more thing, Rick Langston shows that there is very little difference between performance of a subsetting IF statement and a WHERE statement ...

"Efficiency Considerations Using the SAS System"

http://www2.sas.com/proceedings/sugi30/002-30.pdf

and, you can use "OF" in an IF statement, so ...

data a;

set a1-a5;

if PrxMatch( '/c[1-9](?:,|$)/o' , Strip( CatX( ',' , of dx: ) ) );

run;

Mike Zdeb<http://www.albany.edu/~msz03/> U@Albany School of Public Health One University Place (Room 119) Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

________________________________ From: toby dunn [tobydunn@hotmail.com] Sent: Friday, February 10, 2012 12:38 PM To: Zdeb, Michael S; sas-l@listserv.uga.edu Subject: RE: Any easier way?

Mike,

You shouldnt get any observations given your data values...

C[1-9] will only match a 2 character value where the first character is a lowercase 'c' and the next character is a 1-9 digit.

data a1; input (dx1 dx2 dx3) (: $3.); datalines; aaa bbb c1x C1 BBB C2 c3a bbb c19 ; run; data a2; input (dx1 dx2 dx3) (: $3.); datalines; aa9 bbc c3 aa9 c2 ccc aa9 bbc c1 ; run; data a; set a1 a2; where prxmatch( '/c[1-9](?:,|$)/o' , strip( catx( ',' , dx1, dx2,dx3))) ; run;

Here the only observations read will be from data a2, while data a1 C1 and C2 value are upper case and wouldnt be included in the match criteria.... NOw if one wanted a make it case insensitive then its a simple matter of adding one pattern modifier:

where prxmatch( '/c[1-9](?:,|$)/io' , strip( catx( ',' , dx1, dx2,dx3))) ;

Toby Dunn

If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain.

“Any idiot can face a crisis—it’s day to day living that wears you out” ~ Anton Chekhov

> Date: Fri, 10 Feb 2012 17:19:03 +0000 > From: mzdeb@ALBANY.EDU > Subject: Re: Any easier way? > To: SAS-L@LISTSERV.UGA.EDU > > hi ... nice, only problem is that a WHERE statement or data set option does not recogize "OF" > > you have to use all the variable names ... > > Where = ( PrxMatch( '/c[1-9](?:,|$)/o' , Strip( CatX( ',' , DX1,DX2,DX3,DX4,DX5,DX6 ) ) ) ); > > > but if I try that with ... > > data a1; > input (dx1 dx2 dx3) (: $3.); > datalines; > aaa bbb c1x > aaa bbb cxc > c3a bbb cxc > ; > run; > data a2; > input (dx1 dx2 dx3) (: $3.); > datalines; > aa9 bbc c3c > aa9 c2q ccc > aa9 bbc c1c > ; > run; > > data a; > set a1-a2; > where prxmatch( '/c[1-9](?:,|$)/o' , strip( catx( ',' , dx1, dx2,dx3))) ; > run; > > I get zero observations, there should be 5 ... so what am I missing here > > thanks > > Mike Zdeb > U@Albany School of Public Health > One University Place (Room 119) > Rensselaer, New York 12144-3456 > P/518-402-6479 F/630-604-1475 > > ________________________________________ > From: SAS(r) Discussion [SAS-L@LISTSERV.UGA.EDU] on behalf of Ya Huang [ya.huang@AMYLIN.COM] > Sent: Friday, February 10, 2012 11:59 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: Any easier way? > > Thanks Toby, > > You are the RX man :-) > > Ya > > On Fri, 10 Feb 2012 16:48:36 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote: > > >Ya, > > > >Where = ( PrxMatch( '/c[1-9](?:,|$)/o' , Strip( CatX( ',' , Of DX1- > DX6 ) ) ) ; > > > > > >Have to add the last part on there (?:,|$) in case there are values like > C19, which isnt wanted but C1 is... > > > > > > > >Toby Dunn > > > > > >If you get thrown from a horse, you have to get up and get back on, > unless you landed on a cactus; then you have to roll around and scream in > pain. > > > >�Any idiot can face a crisis�it�s day to day living that wears you out� > >~ Anton Chekhov > > > > > > > >> Date: Fri, 10 Feb 2012 11:38:49 -0500 > >> From: ya.huang@AMYLIN.COM > >> Subject: Re: Any easier way? > >> To: SAS-L@LISTSERV.UGA.EDU > >> > >> How about somthing like: > >> > >> where=(prxmatch('/c\d c\d c\d c\d c\d c\d/', > >> catx(' ',dx1,dx2,dx3,dx4,dx5,dx6))); > >> > >> Not tested though. > >> > >> The idea is that if you concatenate dx1-dx6, you should get > >> a string with six word, and at least one of them should be c1 or c2... > c6. > >> > >> > >> On Fri, 10 Feb 2012 11:11:29 -0500, F Sun <sunffang@YAHOO.COM> wrote: > >> > >> >I have the following code: > >> > > >> >data a; > >> >set a1(where=(dx1 in:('c1','c2','c3'...'c9') or dx2 in: > >> >('c1','c2','c3'...'c9') or ... dx6 in:('c1','c2','c3'...'c9'))) > >> > a2(where=(dx1 in:('c1','c2','c3'...'c9') or dx2 in: > >> >('c1','c2','c3'...'c9') or ... dx6 in:('c1','c2','c3'...'c9'))) > >> >... > >> > a5(where=(dx1 in:('c1','c2','c3'...'c9') or dx2 in: > >> >('c1','c2','c3'...'c9') or ... dx6 in:('c1','c2','c3'...'c9'))); > >> >run; > >> > > >> >Any easier way to do it? > >> > > >> >And datasets are large, I donot want to read in all obs. > >> > > >> >Thanks for help! > >> > > >> >F Sun > >


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