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
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)=" " ;
22.214.171.124 UI=DS00000479608& SI=CTPBLU&
126.96.36.199512 UI=0D9614& SI=CTPBLU&
proc print ;
Obs ip ui si
1 188.8.131.52 DS00000479608 CTPBLU
2 184.108.40.206512 0D9614 CTPBLU
On Mon, 11 Sep 2006 13:53:13 -0700, mike.wilson8@COMCAST.NET wrote:
>I have a data file that looks like this.
>220.127.116.11 UI=DS00000479608& SI=CTPBLU&
>18.104.22.168512 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.