问题是压缩掉字符中的 ".txt" 字符,new2其实已经能解决这个问题了
想问的是 new1 和 new2的结果不一样,有些字符被压缩没有了
我想问下是不是我的sas有问题,还是有其他机制,多谢关注
有后续问题,比如导入多个excel的时候名字没有问题,但是多个excel外加多个sheet一起导入的时候
即便没有重名的因素,也会压缩掉一些特殊的字母,比如 “l”,所有的“l”都被压缩没了,就是这个瑕疵
data x;
length name $ 40.;
input name$;
cards;
ww2.txt
oe.txt
ttttt2.txt
xxxxxx3.txt
;run;
data y;set x;
t=length(name);
new1=compress(name,'.txt');
new2=substr(name,1,t-4);
run;
proc print data=y;run;
Obs name t new1 new2
1 ww2.txt 7 ww2 ww2
2 oe.txt 6 oe oe
3 ttttt2.txt 10 2 ttttt2
4 xxxxxx3.txt 11 3 xxxxxx3