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 (August 2006, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 2 Aug 2006 22:31:05 -0500
Reply-To:     Kevin Myers <KMyers1@CLEARWIRE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Kevin Myers <KMyers1@CLEARWIRE.NET>
Subject:      Re: SCAN function
Content-Type: text/plain; charset="iso-8859-1"

FWIW, two delimiters stacked next to each other is exactly how most csv creation programs would create a row that includes a field with a null (missing) value. So this problem is pretty common. Basically, this guy is trying to read a record from a csv file, and the safest approach is to simply use the best SAS tool for the job (input statement with DSD and DLM infile options).

BTW Toby, your new sig file worries me. People who conceive of alternate realities don't really strike me as the best types for programming work! I hate it when a user swears up and down that in their "reality", they didn't make some change to their system which produces some kind of malfunction. When I finally track down the problem to what they actually did, their "reality" most often gets a serious adjustment... ;-)

s/KAM

----- Original Message ----- From: "toby dunn" <tobydunn@hotmail.com> To: <nospam@HOWLES.COM>; <SAS-L@LISTSERV.UGA.EDU> Sent: Wednesday, August 02, 2006 10:12 PM Subject: Re: SCAN function

> True Howard, but then again I wouldnt expect that one would build a list > with delimiters stacked one next to the other with no spaces in between > since they would get treated as one delimiter. I kind of expect posters to > first attempt to solve the problem on their own and at least read the docs > before posting. Plus give working code that mimics the problem they are > trying to solve. > > > > Toby Dunn > > Normal People Worry Me!!!!! > > I reject your reality and substitue my own!!! > > > > > > From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM> > Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM> > To: SAS-L@LISTSERV.UGA.EDU > Subject: Re: SCAN function > Date: Wed, 2 Aug 2006 20:13:27 -0400 > > On Wed, 2 Aug 2006 23:41:51 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote: > > >PoohBear , > > > >Shouldntmake a difference as the scan function could careless if the third > >element from the right is missing or not. In fact I ran your code and > came > >up the right answer. > > > >Data _Null_ ; > > > >X = "abc, def, ght, hugdy, bshdgeyrt, 234, 5476, 037199, , 03/12/2006, > >01/07/2007" ; > > > > > >id=scan(x,-4,','); > > > >Put Id= ; > >Run ; > > > > > >Toby Dunn > > True as long as there are one or more blanks between the commas. > > Try it with > > 037199,, > > and the problem as described occurs. > > I think there should be a SCANDSD function which would force operation like > DSD does for INFILE. > > > > >Normal People Worry Me!!!!! > > > >I reject your reality and substitue my own!!! > > > > > > > > > > > >From: Poohbear <liuberyl@GMAIL.COM> > >Reply-To: Poohbear <liuberyl@GMAIL.COM> > >To: SAS-L@LISTSERV.UGA.EDU > >Subject: SCAN function > >Date: Wed, 2 Aug 2006 16:25:12 -0700 > > > >Hi All, > > > >I have to use the scan function to get the '-4th' value for a string, > >but sometimes the '-3rd' field of that string is a missing value. For > >example, I have a string like this: > > > >abc, def, ght, hugdy, bshdgeyrt, 234, 5476, 037199, , 03/12/2006, > >01/07/2007 > > > >I wanna get the value '037199'. Since I have too many such strings, and > >the number of fileds before the field '037199' are not same for each > >string, so I have to use scan function to scan it from the right to > >left. The problem is, not all strings have missing value for the '-3rd' > >field.... > > > >Here is my statement: > > > >id=scan(txt,-4,','); > > > >But it seems it always give me the value of 5476 for the strings have > >missing value for '-3rd' field. Anyone has a clue of how to avoid this? > > > > > >Thanks a lot, > >Pooh >


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