From: karma on 27 Nov 2009 08:40 Hi Marcelo, The example you give doesn't demonstrate how other possible values should be handled: eg. what if the variable starts with a letter other than Z? The following works with your example and matches against the pattern: - starts with z, followed by any number of a-z characters, followed by any number of space/tab characters, followed by an optional 0 and one digit. All case sensitive. HTH Karma data have; input X $1-10 Y $10-25 ; length Z $10 ; Z = prxchange('s/^z[a-z]*\s*0?(\d{1})\s*$/Zona 0$1/i',-1,x) ; cards ; z 07 Zona 07 z07 Zona 07 z 4 Zona 04 z7 Zona 07 zona 02 Zona 02 zona05 Zona 05 zona 7 Zona 07 zona8 Zona 08 ;;; proc print; run ; Obs X Y Z 1 z 07 Zona 07 Zona 07 2 z07 Zona 07 Zona 07 3 z 4 Zona 04 Zona 04 4 z7 Zona 07 Zona 07 5 zona 02 Zona 02 Zona 02 6 zona05 Zona 05 Zona 05 7 zona 7 Zona 07 Zona 07 8 zona8 Zona 08 Zona 08 2009/11/27 Marcelo Lamack <mar.lamack(a)hotmail.com>: > Dear all, consider the variables X an Y, as bellow, > > X Y > > z 07 Zona 07 > z07 Zona 07 > z 4 Zona 04 > z7 Zona 07 > zona 02 Zona 02 > zona05 Zona 05 > zona 7 Zona 07 > zona8 Zona 08 > > My question: is it possible to create Y using prxchange? If yes, How can I do this? > > Best regards. > > > _________________________________________________________________ > Novo site do Windows Live: Novidades, dicas dos produtos e muito mais. Conhe�a! > http://www.windowslive.com.br/?ocid=WindowsLive09_MSN_Hotmail_Tagline_out09
From: Toby Dunn on 27 Nov 2009 10:59 Marcelo, Well lets see if I have this correct: You have variable X and want variable Y. Well I dont think PrxChange will help you much unless you only have the data you show. Let me elaborate a little here, lets say you have a value of "z 07", now suppose you have to values that Z could possibly be lets say "ZUNA" and "ZETA". Okay how do you know which to apply and when. Now lets take this a bit further and say you know that all values of "z" should be "ZUNA" but you also have other character values that need to be formated into something else such as all "c" values need to be formated into "Charlie" and all "b" values need to be "BRAVO". Now you will need to code in some sort of format inside of the PrxChange and as far as I know you cant do that as the code at that point is off in Perl land and not SAS land. So if you wanted to use PrxChange to break the variable X's values up into two variables, then use some sort of other rules to decide what gets recoded and what doesnt and into what value. Then Use another function to put it all back together. Toby Dunn On Fri, 27 Nov 2009 12:41:36 +0000, Marcelo Lamack <mar.lamack(a)HOTMAIL.COM> wrote: > Dear all, consider the variables X an Y, as bellow, > >X Y > >z 07 Zona 07 >z07 Zona 07 >z 4 Zona 04 >z7 Zona 07 >zona 02 Zona 02 >zona05 Zona 05 >zona 7 Zona 07 >zona8 Zona 08 > >My question: is it possible to create Y using prxchange? If yes, How can I do this? > >Best regards. > > >_________________________________________________________________ >Novo site do Windows Live: Novidades, dicas dos produtos e muito mais. Conhe�a! >http://www.windowslive.com.br/? ocid=WindowsLive09_MSN_Hotmail_Tagline_out09
From: Joe Matise on 27 Nov 2009 11:13 Given that "Zona" means "Zone" in Portuguese, it seems very reasonable that all of the Z's might mean Zona. -Joe On Fri, Nov 27, 2009 at 9:59 AM, Toby Dunn <tobydunn(a)hotmail.com> wrote: > Marcelo, > > Well lets see if I have this correct: > > You have variable X and want variable Y. > > Well I dont think PrxChange will help you much unless you only have the > data you show. > > Let me elaborate a little here, lets say you have a value of "z 07", now > suppose you have to values that Z could possibly be lets say "ZUNA" > and "ZETA". Okay how do you know which to apply and when. Now lets take > this a bit further and say you know that all values of "z" should > be "ZUNA" but you also have other character values that need to be > formated into something else such as all "c" values need to be formated > into "Charlie" and all "b" values need to be "BRAVO". Now you will need > to code in some sort of format inside of the PrxChange and as far as I > know you cant do that as the code at that point is off in Perl land and > not SAS land. > > So if you wanted to use PrxChange to break the variable X's values up int= o > two variables, then use some sort of other rules to decide what gets > recoded and what doesnt and into what value. Then Use another function t= o > put it all back together. > > Toby Dunn > > > > > > > On Fri, 27 Nov 2009 12:41:36 +0000, Marcelo Lamack > <mar.lamack(a)HOTMAIL.COM> wrote: > > > Dear all, consider the variables X an Y, as bellow, > > > >X Y > > > >z 07 Zona 07 > >z07 Zona 07 > >z 4 Zona 04 > >z7 Zona 07 > >zona 02 Zona 02 > >zona05 Zona 05 > >zona 7 Zona 07 > >zona8 Zona 08 > > > >My question: is it possible to create Y using prxchange? If yes, How can > I do this? > > > >Best regards. > > > > > >_________________________________________________________________ > >Novo site do Windows Live: Novidades, dicas dos produtos e muito mais. > Conhe=EF=BF=BDa! > >http://www.windowslive.com.br/? > ocid=3DWindowsLive09_MSN_Hotmail_Tagline_out09<http://www.windowslive.com= ..br/?%0Aocid=3DWindowsLive09_MSN_Hotmail_Tagline_out09> >
From: Toby Dunn on 27 Nov 2009 11:22 Joe, Thanks, my Portuguese sucks errr... well okay non-existent.... All the same if lets say it does mean zone, are there values that correspond to area, hectares....etc... When using Perl one has to really know their data, what pattern they are trying to solve. Which we have only part of what needs to be known here. Which will dictate if PrxChange will even be useful in solving the problem or not. On Fri, 27 Nov 2009 10:13:46 -0600, Joe Matise <snoopy369(a)GMAIL.COM> wrote: >Given that "Zona" means "Zone" in Portuguese, it seems very reasonable that >all of the Z's might mean Zona. > >-Joe > >On Fri, Nov 27, 2009 at 9:59 AM, Toby Dunn <tobydunn(a)hotmail.com> wrote: > >> Marcelo, >> >> Well lets see if I have this correct: >> >> You have variable X and want variable Y. >> >> Well I dont think PrxChange will help you much unless you only have the >> data you show. >> >> Let me elaborate a little here, lets say you have a value of "z 07", now >> suppose you have to values that Z could possibly be lets say "ZUNA" >> and "ZETA". Okay how do you know which to apply and when. Now lets take >> this a bit further and say you know that all values of "z" should >> be "ZUNA" but you also have other character values that need to be >> formated into something else such as all "c" values need to be formated >> into "Charlie" and all "b" values need to be "BRAVO". Now you will need >> to code in some sort of format inside of the PrxChange and as far as I >> know you cant do that as the code at that point is off in Perl land and >> not SAS land. >> >> So if you wanted to use PrxChange to break the variable X's values up into >> two variables, then use some sort of other rules to decide what gets >> recoded and what doesnt and into what value. Then Use another function to >> put it all back together. >> >> Toby Dunn >> >> >> >> >> >> >> On Fri, 27 Nov 2009 12:41:36 +0000, Marcelo Lamack >> <mar.lamack(a)HOTMAIL.COM> wrote: >> >> > Dear all, consider the variables X an Y, as bellow, >> > >> >X Y >> > >> >z 07 Zona 07 >> >z07 Zona 07 >> >z 4 Zona 04 >> >z7 Zona 07 >> >zona 02 Zona 02 >> >zona05 Zona 05 >> >zona 7 Zona 07 >> >zona8 Zona 08 >> > >> >My question: is it possible to create Y using prxchange? If yes, How can >> I do this? >> > >> >Best regards. >> > >> > >> >_________________________________________________________________ >> >Novo site do Windows Live: Novidades, dicas dos produtos e muito mais. >> Conhe�a! >> >http://www.windowslive.com.br/? >> ocid=WindowsLive09_MSN_Hotmail_Tagline_out09<http://www.windowslive.com.br/ ?%0Aocid=WindowsLive09_MSN_Hotmail_Tagline_out09> >>
|
Pages: 1 Prev: The use of estimate statements in proc mixed Next: ODS output error with Proc GLMselect |