Date: Tue, 17 May 2011 21:46:40 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: New variable from string
Content-Type: text/plain; charset="Windows-1252"
Data Need ;
Set Have ;
Pattern = PrxParse( '/(&Campaign=.+&)/io' ) ;
Match = PrxMatch( Pattern , Text ) ;
NewVar = PrxPosn( Pattern , 1 , Text ) ;
Data Need ;
NewVar = PrxChange( 's/.+(&Campaign=.+&).+/$1/io' , 1 , Text ) ;
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: Tue, 17 May 2011 16:31:21 -0500
> From: Kline.Aimee@MAYO.EDU
> Subject: New variable from string
> To: SAS-L@LISTSERV.UGA.EDU
> > I need to make a variable that contains a string of text buried in
> > another variable.
> > The new variable needs to include everything in the existing variable
> > from "&Campaign=" to the next "&". One of the issues that I'm running
> > into is that the string does not start and end in the same place
> > consistently, and it is not the same length.
> > Any help is appreciated!