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 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 11 Sep 2006 17:12:37 -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: INFILE - reading to the ampersand and then stopping
Comments: To: mike.wilson8@COMCAST.NET

Do you know the maximum length of UI? If not you will have to make some guesses and declare a length for your variables before reading them in. Also since you have UI= and SI= as the starting pointers for your UI and SI variables you may use them in your input. Finally in the varying length UI, the & sign can be eliminated with some post processing. You can eliminate the & in SI by simply declaring a length that stores only 6 characters as the example seems to indicate.

data test ; length ip $14 ui $14 si $6 ; input ip $ @ "UI=" ui $ @ "SI=" si $ ; substr(ui,length(ui),1)=" " ; cards ; 57.8.114.82 UI=DS00000479608& SI=CTPBLU& 57.8.114.82512 UI=0D9614& SI=CTPBLU& run ;

proc print ; run ;

Yields:

Obs ip ui si

1 57.8.114.82 DS00000479608 CTPBLU 2 57.8.114.82512 0D9614 CTPBLU

Venky Chakravarthy

On Mon, 11 Sep 2006 13:53:13 -0700, mike.wilson8@COMCAST.NET wrote:

>I have a data file that looks like this. > >57.8.114.82 UI=DS00000479608& SI=CTPBLU& >57.8.114.82512 UI=0D9614& SI=CTPBLU& > >It's space delimted and is suppose to have 3 columns..IP, UI, SI > >Because the UI character length varies, I'm trying to read the UI info >and stop at the ampersand. > >When I initially suck the data in, it cuts off the UI info and only >reads so many characters so this snippet of code doesn't work: input >IP$ UI$ SI$...doesn't read all the UI characters. > >I'm a newbie at this so any advice you have would be great. > >Thank you, >Mike


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