Note that you will have a similar issue when using the $ INFORMAT to read in the original file.
Consider this text file:
This in example
file with some
lines with
leading
spaces. And some lines
without.
You can read it in using the automatic _INFILE_ variable.
data have;
infile rtf ;
input;
line=_infile_;
run;
Or use the $CHAR informat.
data have;
infile rtf truncover;
input line $char300.;
run;
Then you can write it out using the $VARYING format.
data _null_;
set have;
file out;
len=lengthn(line);
put line $varying300. len ;
run;
You can use the LIST statement to check the contents:
56 data _null_;
57 infile out;
58 input;
59 list;
60 run;
NOTE: The infile OUT is:
Filename=C:\Users\...\#LN00012,
RECFM=V,LRECL=32767,File Size (bytes)=103,
Last Modified=25Apr2025:07:59:58,
Create Time=25Apr2025:07:59:58
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+---
1 This in example 15
2 file with some 16
3 lines with 15
4 leading 14
5 spaces. And some lines 23
6 without. 8
NOTE: 6 records were read from the infile OUT.
The minimum record length was 8.
The maximum record length was 23.
NOTE: DATA statement used (Total process time):
real time 0.01 seconds
cpu time 0.01 seconds
... View more