SAS 无效数据 [英] SAS Invalid Data
问题描述
我有一个包含数字数据的数据集.代码如下:
I have a data set with numeric data. The code is below:
data test;
infile 'C:\Users\Public\Documents\Test\test.dat';
input a1 a2 a3 a4 b1 b2 b3 b4;
run;
proc print data=test;
run;
当我运行它时,我收到以下错误消息:
When I run this I get the following error messages:
NOTE: Invalid data for a1 in line 1 1-51.
NOTE: Invalid data for a2 in line 2 1-50.
NOTE: Invalid data for a3 in line 3 1-50.
NOTE: Invalid data for a4 in line 4 1-50.
NOTE: Invalid data for b1 in line 5 1-51.
NOTE: Invalid data for b2 in line 6 1-51.
NOTE: Invalid data for b3 in line 7 1-51.
NOTE: Invalid data for b4 in line 8 1-51.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+-
8 CHAR 18.597.6.261.4.032.0.215.-0.099.32.580.36.430.1.038 51
ZONE 332333032333032333032333023233303323330332333032333
NUMR 18E59796E26194E03290E2159D0E099932E580936E43091E038
我该如何解决这个问题?出现此错误消息是否是因为数字位数过多?
How do I fix this? Does this error message come up because the numbers have too many digits?
已添加.以下是我的数据中的一些示例行:
Added. Here are some sample lines from my data:
21.312 7.039 5.326 .932 -.030 35.239 36.991 1.057
21.206 6.979 5.237 .871 .015 35.713 36.851 1.064
这里也是错误信息的另一部分:
Also here is another part of the error message:
NOTE: Invalid data errors for file ''C:\Users\Public\Test\test.dat'' occurred
outside the printed range.
NOTE: Increase available buffer lines with the INFILE n= option.
推荐答案
看起来 SAS 将每一行视为一个变量,而不是一个包含多个变量的观察,这告诉我它没有正确识别分隔符.如果在您发布的示例行中,分隔符是一个空格,则您的代码应该可以工作.或者,您可以通过执行以下操作来确保它使用空格分隔的格式:
It looks like SAS is seeing each line as one variable rather than one observation with multiple variables, which tells me it's not recognizing the delimiter correctly. If, as in the sample lines you posted, the delimiter is a space, your code should work. Alternatively, you can make sure it's using a space delimited format by doing the following:
data test;
infile "C:\Users\Public\Documents\Test\test.dat" dlm=" ";
input a1 a2 a3 a4 b1 b2 b3 b4;
run;
如果它实际上是制表符分隔的,您可能需要改用 dlm='09'x
.
If it's actually tab delimited, you may need to use dlm='09'x
instead.
如果这有帮助,请告诉我们.
Let us know if that helps.
这篇关于SAS 无效数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!