| Date: | Wed, 13 Jul 2011 10:15: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: Read in an entire line of raw data including the leading
spaces |
|
| In-Reply-To: | <CALJjakGRmegc1wMS0tNr_it6zDn+y-K92Z5P3EWYE1-K7mehQg@mail.gmail.com> |
| Content-Type: | text/plain; charset=ISO-8859-1 |
|---|
Well, you have an issue here that SAS considers a missing character field to
be a single blank space [or any number thereof]. So "" doesn't really
exist, it evaluates to " ".
Sounds like Randy has a good solution with the LENGTH attribute (I was
poking around with $HEX and some other raw-er formats, but wasn't having any
luck), so go with that if it works for your purposes.
-Joe
On Wed, Jul 13, 2011 at 10:03 AM, John Smith <js8765@googlemail.com> wrote:
> 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
> >
>
|