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 (July 2011, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 13 Jul 2011 15:10:07 +0000
Reply-To:     Randy Herbison <RandyHerbison@WESTAT.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Randy Herbison <RandyHerbison@WESTAT.COM>
Subject:      Re: Read in an entire line of raw data including the leading
              spaces
Comments: To: John Smith <js8765@GOOGLEMAIL.COM>
In-Reply-To:  <CALJjakGRmegc1wMS0tNr_it6zDn+y-K92Z5P3EWYE1-K7mehQg@mail.gmail.com>
Content-Type: text/plain; charset="us-ascii"

283 filename test temp; 284 285 data _null_; 286 file test; 287 put / ' '; 288 run;

NOTE: The file TEST is: Filename=C:\DOCUME~1\HERBIS~1\LOCALS~1\Temp\SAS Temporary Files\_TD2932\#LN00016, RECFM=V,LRECL=256,File Size (bytes)=0, Last Modified=13Jul2011:11:08:29, Create Time=13Jul2011:11:08:29

NOTE: 2 records were written to the file TEST. The minimum record length was 0. The maximum record length was 1. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.00 seconds

289 290 data _null_; 291 infile test length=length; 292 input; 293 put length=; 294 run;

NOTE: The infile TEST is: Filename=C:\DOCUME~1\HERBIS~1\LOCALS~1\Temp\SAS Temporary Files\_TD2932\#LN00016, RECFM=V,LRECL=256,File Size (bytes)=5, Last Modified=13Jul2011:11:08:29, Create Time=13Jul2011:11:08:29

length=0 length=1

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of John Smith Sent: Wednesday, July 13, 2011 11:04 AM To: SAS-L@LISTSERV.UGA.EDU Subject: Re: Read in an entire line of raw data including the leading spaces

Hi,

Thanks to you both for the help. I now realise that I should have specified my problem a bit more...

I'd like to be able to distinguish between a line with no characters and a line with just one space in it.

Here's what I tried but it gives the same result for both if statments...

data _null_; infile temp; input; if put(_infile_,$char.) = "" then put 'Empty line'; if put(_infile_,$char.) = " " then put 'Line with a single space'; run;

Any further help would be great.

Thanks.

On Wed, Jul 13, 2011 at 4:20 PM, Randy Herbison <RandyHerbison@westat.com>wrote:

> They don't get removed from the _infile_ variable. When you PUT the > _infile_ variable, use a $CHAR format to see leading spaces: > > 26 filename test temp; > 27 > 28 data _null_; > 29 file test; > 30 put @8 'ABC123'; > 31 run; > > NOTE: The file TEST is: > Filename=C:\DOCUME~1\HERBIS~1\LOCALS~1\Temp\SAS Temporary > Files\_TD2932\#LN00012, > RECFM=V,LRECL=256,File Size (bytes)=0, > Last Modified=13Jul2011:10:17:34, > Create Time=13Jul2011:10:17:34 > > NOTE: 1 record was written to the file TEST. > The minimum record length was 13. > The maximum record length was 13. > NOTE: DATA statement used (Total process time): > real time 0.03 seconds > cpu time 0.01 seconds > > > 32 > 33 data _null_; > 34 infile test _infile_=myInfile; > 35 input; > 36 put _infile_; > 37 put myInfile $char13.; > 38 run; > > NOTE: The infile TEST is: > Filename=C:\DOCUME~1\HERBIS~1\LOCALS~1\Temp\SAS Temporary > Files\_TD2932\#LN00012, > RECFM=V,LRECL=256,File Size (bytes)=15, > Last Modified=13Jul2011:10:17:34, > Create Time=13Jul2011:10:17:34 > > ABC123 > ABC123 > > -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of John > Smith > Sent: Wednesday, July 13, 2011 10:07 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Read in an entire line of raw data including the leading spaces > > Hi, > > When I read in a line of raw data using the input statement, the leading > spaces are stripped from the _infile_ variable. > > Is there any way of reading in an entire line of raw data and conserve the > leading spaces? > > Thanks for any help, > > js >


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