无法在 SAS 中导入带有异常字符的文本分隔文件 [英] Cannot import text delimited file with unusual characters in SAS

查看:43
本文介绍了无法在 SAS 中导入带有异常字符的文本分隔文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 SAS 中导入一个制表符分隔的文件,如下所示,

Hi I am trying to import a tab delimited file in SAS that looks like this,

Names   Points
Sumit1  10
Sumit2  20
SUmit4  30
SUmit5  85
SUmit6  90
SUmit7  39
hfgö®q-±òSÀ®téîÓVU«‘îj'n5E•d÷Yb#­AK$®SŽ†ÿ-ÍKÕw¿óå0"¤h—t0Ld        89
SUmit8  48
SUmit9  70
SUmit10 20
SUmit11 90

第一行代表列名.

我正在使用以下代码导入文件,

I am using the following code to import the file,

data names;
infile "C:xxxxxxxx\names.txt" 
delimiter='09'x MISSOVER DSD lrecl=32767 firstobs=2;
informat names $150.;
informat Points best32.;
format names $150.;
format Points best12.;
input names $
Points;
run;

导入后的sas数据集如下所示:

and the sas data set after import looks like the following:

Names                                                     Points
Sumit1                                                  10
Sumit2                                                  20
SUmit4                                                  30
SUmit5                                                  85
SUmit6                                                  90
SUmit7                                                      39
hfgö®q-±òSÀ®téîÓVU«‘îj'n5E•d÷Yb#­AK$®SŽ†ÿ-ÍKÕw¿óå0"¤h—t0Ld             .

所以基本上所有的行都没有被导入到 sas 中,因为存在一些不寻常的字符,它停在第 7 行(我不知道这些字符叫什么).

So basically all the rows are not getting imported in sas and it stops at row 7 because of the presence of some unusual characters (I don't know what what this characters are called).

我需要导入 1000 个这样的文件.所以我使用宏来导入文件.有人可以帮助我如何在 SAS 中导入此类文件.

There are 1000 files like this that I need to import. So I am using a macro to import the files. Can somebody please help me how can I import this type of files in SAS.

推荐答案

试试这个代码....

DATA names;
LENGTH Names $ 91 Points 8 ;
FORMAT Names  $CHAR91. Points  BEST2. ;
INFORMAT Names  $CHAR91. Points           BEST2. ;
INFILE 'C:xxxxxxxx\names.txt'
LRECL=32767 ENCODING="LATIN1" TERMSTR=CRLF DLM='7F'x MISSOVER DSD ;
INPUT Names : $CHAR91. Points : ?? BEST2. ;
RUN;

这篇关于无法在 SAS 中导入带有异常字符的文本分隔文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆