- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
When reading a text file using the INFILE statement, the documentation tells me that the delimiter between variables is a space. However, I want to read an entire line of text that contains spaces - as a single variable. I believe to override the space delimiter, I need to use the delimiter= option on the INFILE statement. However, I can't seem to find the right character(s) to override the default. I've used DLM='' and DLM='0x0D'x and DLM=CRLF all without the result I need.
My current program looks like this:
DATA TEMPFILE ;
ATTRIB TEMPLINE LENGTH = $200 ;
INFILE "C:\TEMP.TXT" DELIMITER = '0x0D'x ; /* or DELIMITER = '' */
INPUT TEMPLINE ;
RUN ;
where TEMP.TXT is:
FIRSTWORD SECONDWORD MOREWORDS
THISISAVERYLONG WORD
TEST!TEST@TEST# test
The program only grabs the data before the first space. I can't seem to override this. I know I'm simply missing some option but I can't seem to find it reading the documentation or googling for examples. Thanx in advance...
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You don't need to mess with the delimiter to read a full line.
Just use formatted input. Use the TRUNCOVER infile option to handle short lines. Use the $CHAR informat to preserve any leading spaces on the line.
Or just use the _INFILE_ automatic variable.
DATA TEMPFILE ;
ATTRIB TEMPLINE LENGTH = $200 ;
INFILE "C:\TEMP.TXT" TRUNCOVER;
INPUT TEMPLINE $char200.;
RUN ;
DATA TEMPFILE ;
ATTRIB TEMPLINE LENGTH = $200 ;
INFILE "C:\TEMP.TXT" ;
INPUT ;
TEMPLINE= _infile_;
RUN ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You don't need to mess with the delimiter to read a full line.
Just use formatted input. Use the TRUNCOVER infile option to handle short lines. Use the $CHAR informat to preserve any leading spaces on the line.
Or just use the _INFILE_ automatic variable.
DATA TEMPFILE ;
ATTRIB TEMPLINE LENGTH = $200 ;
INFILE "C:\TEMP.TXT" TRUNCOVER;
INPUT TEMPLINE $char200.;
RUN ;
DATA TEMPFILE ;
ATTRIB TEMPLINE LENGTH = $200 ;
INFILE "C:\TEMP.TXT" ;
INPUT ;
TEMPLINE= _infile_;
RUN ;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Appreciated!!!