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 (September 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 27 Sep 2006 16:26:38 -0400
Reply-To:     Chang Chung <chang_y_chung@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Chang Chung <chang_y_chung@HOTMAIL.COM>
Subject:      Re: How to get "YET???" to become "YET?"
Comments: To: Charles Patridge <charles_s_patridge@PRODIGY.NET>

On Wed, 27 Sep 2006 11:34:50 -0400, Charles Patridge <charles_s_patridge@PRODIGY.NET> wrote:

>Thanks for the assistance - I am going to use AG's solution - much shorter >and to the point - sorry <grin> > >The following should do it. > > data one; > input x $; > cards; > one? > two?? > three??? > four???? > five????? > ; > run; > > data two; > set one; > justone=prxchange('s/\?+/?/',-1,x); > run; ...


I wouldn't go with the data step two above, since I am not sure if I have explicit control over the length of the new variable, justone. So, I would put a length statement (or a retain or attrib or just an assignment or whatever...). Also the negative one (-1) does not make sense because the goal seems to replace the trailing conjecutive multiple quotation marks into one. If this is what you aim for and you should not do (-1) since it would do much more. So, it comes down to something like:

data three; set one; length justone $8; justone=prxchange('s/\?+/?/',1,x); run;

Now given this neccessary modification, it looks so much like (sas) rx solution:

data four; set one; length justone $8; call rxchange(" '?'+ to '?' ", 1, x, justone); run;

Or, it seems to me that the sas rx looks much easier to read than prx solution. :-)

I totally agree with data _null_ in that the guy who wrote sas rx is not bad at all. I rather feel that si lost an opportunity to make sas's version of rx much more powerful by switching to perl rx. By definition, perl rx is made to work in perl not in sas. So perl rx in sas will always be something short of the real perl rx running inside perl. si could have extended sas rx so that it could take full advantage of sas such as calling sas data step functions or statements inside the rx, for example. If compatibility was an issue, then si could have made the sas rx an open source and given it away free, too, as perl did... I know I am dreaming :-)

Cheers, Chang

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