Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How keep intent space or tab in output external file?

Status
Not open for further replies.

6656

Programmer
Nov 5, 2002
104
US
Hi, Does anyone have an idea that how to keep the indent spaces or tabs from an input Ascii file to an output external file?
i.e.,
the input file, pgmfile.sas looks like..
data _null_;
set abc;
xyz=123;
......
run;

The indent spaces and tabs were gone and all line flash left in the output file. How to fix it?

data _null_ ;
infile 'c:\aaa\pgmfile.sas' truncover;
input dataline $ 1-200 ;
file 'c:\aaa\num_pgmfile.txt';
put _n_ dataline;
run;

Thanks,
Mike
 
I am not sure what exactly you want. But _infile_ buffer may help you with what you need. See the following example. If you don't want to truncating copied records, then you don't need the length option in the infile statement.

data test;
infile datalines length = len;
input;
len = 10;
put _infile_;
datalines;
1 1 1 1 1 1 1 1 1 2 2 2 2
2 1 1 1 1 1 1 1 1 1 1 1 1
3 2 2 2 2 2 2 2 2 2 1 1 1
4 1 2 1 1 1 1 1 1 1 1 1 1
5 2 2 2 2 2 2 2 2 2 2 2 2
6 2 -2 6 2 2 2 2 2 2 2 2 2
7 2 . 2 2 2 2 2 2 2 2 2 2
;


 
Thanks Teralearner,
I meat that I want add line numbers in the pgmfile.sas and try use below code to accomplish it.
data _null_ ;
infile 'c:\aaa\pgmfile.sas' truncover;
input dataline $ 1-200 ;
file 'c:\aaa\num_pgmfile.txt';
put _n_ dataline;
run;

But the result in mun_pgmfile.txt looks like below:

1 data _null_;
2 set abc;
3 xyz=123;
4 ......
5 run;

 
Try this:

data _null_;
infile 'c:\aaa\pgmfile.sas';
file 'c:\aaa\pgmfile.txt';
input;
put _n_ _infile_;
run;
 
Thanks Teralearner again,
It works well. I couldn't find the tricky (no variable list for INPUT) descripted in the SAS L reference.
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top