我一直在试图从具有行像下方,并具有分隔符为分号的文本文件阅读:遇到分隔符,直到
Sun rises
in the east
and;
sets in the
west
;
我想读从分隔符的数据在单单独的记录分隔符像下面 变量名
1 Sun rises in the east and
2 sets in the west
我已经尝试了几乎所有可用infile
选项无济于事的选项。是否可以像上面那样阅读?怎么做?任何线索/帮助将不胜感激。
我一直在试图从具有行像下方,并具有分隔符为分号的文本文件阅读:遇到分隔符,直到
Sun rises
in the east
and;
sets in the
west
;
我想读从分隔符的数据在单单独的记录分隔符像下面 变量名
1 Sun rises in the east and
2 sets in the west
我已经尝试了几乎所有可用infile
选项无济于事的选项。是否可以像上面那样阅读?怎么做?任何线索/帮助将不胜感激。
recfm=n
是告诉SAS没有“换行符”的方法。所以:
data want;
infile "c:\temp\test.txt" recfm=n dsd dlm=';';
length text $1024;
input text $;
run;
注意,换行符将被读取只是一个两个字符,所以如果你想删除这些字符,你可以使用compress
与c
选项删除控制字符(包括LF/FF)。
读它一字一句,并连接成更长的线。
data want ;
infile mydat end=eof ;
length word $200 line $2000 ;
drop word;
do while (^eof and ^index(word,';'));
input word @ ;
line = catx(' ',line,compress(word,';'));
end;
if _n_ > 1 or line ne ' ' then output;
run;
谢谢汤姆,请你抽出时间。这也是一个很好的解决方案。 – NEOmen
后你已经试过 – Reeza
已经使用LRECL,LINESIZE尝试,@@和所有的,没有他们被给予正确的结果,已经尝试这么多东西。 – NEOmen
它看起来像你,如果多个空间被压缩到一个不在乎?因此,东部和东部将变成东部和东部。如果是这样,那么只需逐字阅读,并在单词包含分隔符时停止。 – Tom