SAS 将换行符/回车符 return 替换为 space
SAS Replace line break / carriage return with a space
我想读取文件并将所有换行符/回车符 return 替换为 space。你能帮忙吗?
/*input.txt*/
<li
data-linked-resource-type="userinfo" data-base-url="https://gbr.host.com/cc">Jean
Paul
Gautier
</a></li>
/*Required output*/
<li data-linked-resource-type="userinfo" data-base-url="https://gbr.host.com/cc">Jean Paul Gautier</a></li>
/*sas datastep*/
data inp;
infile "c:/tmp/input.txt";
/*ADD LOGIC*/
infile "c:/tmp/output.txt";
run;
我建议您逐行阅读文本文件,然后将这些行连接在一起。
data inp;
length x 0. y 0.;
retain y "";
infile "d:/input.txt" dsd truncover;
input x $;
y=catx(" ",y, x); /*concat every line seperated by a space*/
run;
data _null_;
set inp end=EOF ;
FILE 'd:\input2.txt' ; /* Output Text File */
if eof ; /*only last observation has full concatinated string*/
y=compbl(y); /*remove additional spaces*/
PUT y;
run;
否则,您可以按照我在上一个问题中向您展示的方式替换换行符:
tranwrd(mydata,'0A'x, " ");
我想读取文件并将所有换行符/回车符 return 替换为 space。你能帮忙吗?
/*input.txt*/
<li
data-linked-resource-type="userinfo" data-base-url="https://gbr.host.com/cc">Jean
Paul
Gautier
</a></li>
/*Required output*/
<li data-linked-resource-type="userinfo" data-base-url="https://gbr.host.com/cc">Jean Paul Gautier</a></li>
/*sas datastep*/
data inp;
infile "c:/tmp/input.txt";
/*ADD LOGIC*/
infile "c:/tmp/output.txt";
run;
我建议您逐行阅读文本文件,然后将这些行连接在一起。
data inp;
length x 0. y 0.;
retain y "";
infile "d:/input.txt" dsd truncover;
input x $;
y=catx(" ",y, x); /*concat every line seperated by a space*/
run;
data _null_;
set inp end=EOF ;
FILE 'd:\input2.txt' ; /* Output Text File */
if eof ; /*only last observation has full concatinated string*/
y=compbl(y); /*remove additional spaces*/
PUT y;
run;
否则,您可以按照我在上一个问题中向您展示的方式替换换行符:
tranwrd(mydata,'0A'x, " ");