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 2005, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 26 Sep 2005 11:09:41 -0400
Reply-To:   Venky Chakravarthy <swovcc@HOTMAIL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Venky Chakravarthy <swovcc@HOTMAIL.COM>
Subject:   Re: A SAS Question
Comments:   To: Carol Srna <csrna@FORD.COM>

How about

data test ; length dsn $44 ; input @1 dsn $char44. ; cards ; XYSZZ.99.JCL.COPY.G4404V00 ZIIRS.S13.CAS1994 SYSLO CAROL 99.JCL.COPY.G4404V00 ANYHILVL S13 run ;

data test2 ; set test ; if substr(dsn,length(scan(dsn,1))+1,1)^="." then delete ; run ;

Here, the SCAN operates with the default set of delimiters. In your case it is either a period or a blank. Find the length of the string returned by the SCAN and add 1 to it to determine the position right after it. Look at that byte with a SUBSTR. If it is not a period then delete that observation. If you want only blanks to be deleted then change the RHS of the equation accordingly. If the volume of data is huge and it meets other conditions to make a WHERE statement more efficient then use that.

where substr(dsn,length(scan(dsn,1))+1,1)="." ;

Venky Chakravarthy

On Mon, 26 Sep 2005 10:22:13 -0400, Srna, Carol (C.) <csrna@FORD.COM> wrote:

>Hi. > >I have a 44 byte character field named DSN. > >Examples of values for field DSN: >XYSZZ.99.JCL.COPY.G4404V00 > > ZIIRS.S13.CAS1994 > > >If a value in the DSN does not have a period (dot) behind the first >hi-level qualifer, I want to discard that record/observation. >Example: >SYSLO (followed by a blank) >CAROL(followed by a bank) >ANYHILVL (followed by a blank). > >Any ideas/tips on how I can do this? > >I am researching SUBSTR and maybe INDEX functions. > >Thanks In Advance >~~Carol


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