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 (May 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 14 May 2009 09:25:58 -0500
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Infile trouble
In-Reply-To:  <C4A8805C2D21D643B4DA7DF789C4FEB1070ACD93@VANCRMSGA2.vha.med.va.gov>
Content-Type: text/plain; charset=ISO-8859-1

Or just:

data all; format var1 $40. var2 $3.; infile hosp truncover firstobs=2 dlm='09'x; input var1 $40. var2 $3.; run;

Looks like the third part is not necessary. -Joe

On Thu, May 14, 2009 at 9:19 AM, Bross, Dean S <dean.bross@va.gov> wrote:

> This data contains a TAB character '09'x to separate parts of the > data. You can try using the following code to break the VAR1 string > into its parts. I have assumed there are three parts, but you can > use more or less if necessary. > > length y1-y3 $ 30 ; > y1=scan(var1,1,'09'x) ; > y2=scan(var1,2,'09'x) ; > y3=scan(var1,3,'09'x) ; > > > -----Original Message----- > From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] > On Behalf Of Kevin Y > Sent: Thursday, May 14, 2009 9:40 AM > To: SAS L > Subject: Re: Infile trouble > > Thanks Gerhard. I did as you said in your first email, but really do not > know what they mean. > > Below is the SAS run result based on your second email. > > Total 18 records. > > By the way, I have to leave office at 9:42 EST. > > 225 put var1 = hex60.; > 226 put var2 = hex60.; > 227 run; > VAR1=4154454E4F4C4F4C09594553092020202020202020202020202020202020 > VAR2=202020 > VAR1=424C4F505245535320504C55530959455309202020202020202020202020 > VAR2=202020 > VAR1=43414E444553415254414E09594553092020202020202020202020202020 > VAR2=202020 > VAR1=434150544F5052494C095945530920202020202020202020202020202020 > VAR2=202020 > VAR1=454E414C415052494C095945530920202020202020202020202020202020 > VAR2=202020 > VAR1=4655524F53454D4944450959455309202020202020202020202020202020 > VAR2=202020 > VAR1=485944524F43484C4F524F544849415A4944450959455309202020202020 > VAR2=202020 > VAR1=485944524F43484C4F524F544849415A4944452F4F4C4D4553415254414E > VAR2=202020 > VAR1=48595A414152095945530920202020202020202020202020202020202020 > VAR2=202020 > VAR1=4C4F53415254414E20504F5441535349554D095945530920202020202020 > VAR2=202020 > VAR1=4D455448594C444F50410959455309202020202020202020202020202020 > VAR2=202020 > VAR1=4E494645444950494E450959455309202020202020202020202020202020 > VAR2=202020 > VAR1=4F4C4D4553415254414E0959455309202020202020202020202020202020 > VAR2=202020 > VAR1=4F4C4D4553415254414E204D45444F584F4D494C09594553092020202020 > VAR2=202020 > VAR1=50524F5052414E4F4C4F4C09594553092020202020202020202020202020 > VAR2=202020 > VAR1=52414D495052494C09594553092020202020202020202020202020202020 > VAR2=202020 > VAR1=535049524F4E4F4C4143544F4E4509594553092020202020202020202020 > VAR2=202020 > VAR1=564153455245544943095945530920202020202020202020202020202020 > VAR2=202020 > NOTE: 18 records were read from the infile TX. > > > > > > ________________________________ > From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE> > To: SAS-L@LISTSERV.UGA.EDU > Sent: Thursday, May 14, 2009 9:21:05 PM > Subject: Re: Infile trouble > > we had the same problem with UNIX / PC. So it might be a way to have a > look at the resulting variable's contents. With the format $hex60. (long > enough, cause you need the double length for hex-representation) you > should see what is the difference. Just put the two key-variables (which > you compare) like: > > put var1 hex60.; > put var2 hex60.; > > Then you should see the difference. > We first had the problem that we had DI-Studio on UNIX (where the problem > occured) and it was a "quicker" method to look on windows, where we had a > base-SAS installation. The problem was, that the transport tool removed > the UNIX specific characters for CR/LF and we didn't see anything. > So you should write a test program on the system where you see the problem > ans compare the 2 chars. If you find some differences, e.g a hex-0D, just > remove that: > > var1 = translate(var1," ","0D"x); > > Gerhard > > > > > On Thu, 14 May 2009 07:53:02 -0500, Data _null_; <iebupdte@GMAIL.COM> > wrote: > > >input var1 :$40. var2 :$3.; > > > >See what happens if you add the COLON modifer to your INPUT statement. > > Example above. > > > > > >On 5/14/09, Kevin Y <kevin77711@yahoo.com> wrote: > >> Thanks, Data _null_. > >> > >> The "^M"s were successfully removed by TERMSTR =CRLF. > >> > >> But I still could not merge the file with another file by var1 (with > same length and same format). Like Gerhard pointed out that there may be > other chars and I can not see. > >> > >> > >> > >> > >> ________________________________ > >> From: "Data _null_;" <iebupdte@gmail.com> > >> To: Kevin Y <kevin77711@yahoo.com> > >> Cc: SAS-L@listserv.uga.edu > >> Sent: Thursday, May 14, 2009 7:48:21 PM > >> Subject: Re: Infile trouble > >> > >> Did the file come from Windows and your program is on UNIX? > >> > >> Try the INFILE statement option TERMSTR =CRLF; > >> > >> On 5/14/09, Kevin Y <kevin77711@yahoo.com> wrote: > >> > All; > >> > > >> > I have trouble to read in a txt file(below). > >> > > >> > data all; > >> > format var1 $40. var2 $3.; > >> > infile hosp truncover firstobs=2 dlm=z; > >> > input var1 $40. var2 $3.; > >> > run; > >> > > >> > proc print;run; > >> > > >> > Obs VAR1 VAR2 > >> > 1 ATENOLOL YES ^M > >> > 2 BLOPRESS PLUS YES ^M > >> > > >> > Var1=drug used by a patient, Var2=used or not. > >> > 1. How can I efficiently remove the "^M"? > >> > 2. After I removed the "^M" (not efficient at all), I could not merge > the file with another file by var1 (with same length and same format). > There may be something behind the screen. > >> > Thanks. > >> > > >> > > >> > > >> > > >> > >> > >> > >> > >> >


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