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 (November 2010, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 10 Nov 2010 23:10:51 -0800
Reply-To:     "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: KSCAN
In-Reply-To:  <002801cb8167$132caa60$3985ff20$@com>
Content-Type: text/plain; charset=utf-8

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > bbser2009 > Sent: Wednesday, November 10, 2010 10:10 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: KSCAN > > I am not quite sure about what the SAS document says about KSCAN. > It seems that KSCAN returns the n-th word in the string, right? > > > > If I would like the function returns the word of we in the following, > what > number for the question mark? Or do we need other parameter? > > kcan('She says: "we are here." ', ?) > > Thanks. > Max

Well, you can always try it out and see what you get. But, kscan appears to me to be a little less flexible than scan, so unless it is necessary I would opt for scan. In order to get the word "we" (without quotes) you need to specify all punctuation as delimiters. With kscan you need to actually list the delimiters in a string constant, because the default delimiters don't include quotes or colon. At a minimum for your string you would need space, colon, period, and double-quote, ' :."'. I use the default delimiters, with colon and double-quote added.

data _null_; word = kscan('She says: "we are here." ', 3, ' .<(+&!$*);:^-/,%|"'); put 'word = ' word; run;

With scan you could just specify a blank as delimiter, then use the 'p' modifier to add all punctuation.

data _null_; word = scan('She says: "we are here." ', 3, ' ', 'p'); put 'word = ' word; run;

Hope this is helpful,


Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204

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