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 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 3 Sep 2002 10:16:35 +0530
Reply-To:   Arunk@DELHI.TCS.CO.IN
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Arun Kumar <Arunk@DELHI.TCS.CO.IN>
Subject:   Re: tranwrd
Comments:   To: Doug <queanbeyan@HOTMAIL.COM>
Content-Type:   text/plain; charset="us-ascii"

Hi Doug, One of the way to get your desired result may be use of INDEX function ( INDEX(source,excerpt), which searches the source for the character string specified by the excerpt.). You can use like this.

data joe; input name $8.; datalines; robin q joe ; run; data jill; set joe; if index(name, 'joe') > 1; run;

As for tranwrd function you are using, it replaces or removes all occurrences of a word in a character string. So when you are using tranwrd in if statement it replaces 'joe' with xyz (not in the dataset) and compare with 'xyz' and as after getting replaced 'q joe' becomes 'q xyz' so you are getting no obs. Once you remove 'q', you have 'joe' replaced as 'xyz' and so you are getting that observation 'q joe' in the dataset jill.....

Regards Arun Kumar

Doug <queanbeyan@HOTMAIL.COM> Sent by: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> 09/03/2002 08:36 AM Please respond to Doug

To: SAS-L@LISTSERV.UGA.EDU cc: Subject: tranwrd

Hi,

I wish to ouput to a new dataset based on if a variable contains a particular string. However I cannot seem to get SAS to output based on the second line of data 'q joe' (if I take the q away then it works fine). Is there a trick to this or am I using the wrong routine. I can do this with sql and 'where name contains ...' but I am intrigued by a colleague who mentioned using tranwrd for this.

data joe; input name $8.; datalines; robin q joe ; run; data jill; set joe; if tranwrd(name,'joe','xyz') eq 'xyz'; run;

Thanks

Doug


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