s******r 发帖数: 1524 | 1 读txt file, 一个18位的整数,无论是数字还是字符,最后两位总是读不对,前16位
都没问题。Any idea?
Thx |
l*********s 发帖数: 5409 | 2 SAS? maybe you need to specify informats |
s******r 发帖数: 1524 | 3 format best19. informat best19.
format $18. informat $18.
都试了,不work. 很怀疑SAS当float读入,最后几位给截掉了。
【在 l*********s 的大作中提到】 : SAS? maybe you need to specify informats
|
l***a 发帖数: 12410 | 4 应该是你code有问题
给个txt的片断加上你的code一块看看
【在 s******r 的大作中提到】 : format best19. informat best19. : format $18. informat $18. : 都试了,不work. 很怀疑SAS当float读入,最后几位给截掉了。
|
s******r 发帖数: 1524 | 5 data test;
LENGTH key1 8 key2 8 id1 8 id2 8;
FORMAT key1 BEST6. key2 BEST6. id1 $19. id2 $19.;
INFORMAT key1 BEST6. key2 BEST6. id1 $19. id2 $19.;
INPUT key1 : BEST6. key2 : BEST3. id1 : $19. id2 : $19.;
INFILE datalines DLM='7C'x MISSOVER DSD;
datalines;
18949|21|1942303098494173209 |1368841116323724091
;
run;
【在 l***a 的大作中提到】 : 应该是你code有问题 : 给个txt的片断加上你的code一块看看
|
h********o 发帖数: 103 | 6 In SAS, numeric variables are stored in 8-byte floating point form and the
numbers have a precision of about 16 significant digits. Therefore, you last
two digits are not the same as the original data because of rounding error. |
h********o 发帖数: 103 | 7 You can use character instead:
Suppose your text file have a numeric value: 123456789012345678
====================
data test;
infile "h:\test.txt";
input score : $18.;
run;
proc print data = test;
run;
=====================
Obs score
1 123456789012345678 |
s******r 发帖数: 1524 | 8 I did use $19. in my sample code. Still not right with last digits.
【在 h********o 的大作中提到】 : You can use character instead: : Suppose your text file have a numeric value: 123456789012345678 : ==================== : data test; : infile "h:\test.txt"; : input score : $18.; : run; : proc print data = test; : run; : =====================
|
h********o 发帖数: 103 | 9 Why you use both LENGTH and INFORMAT statements? also you define your ID1,
ID2 variables as character in the INPUT statement, you should use:
length ID1 $8 ID2 $18;
not
length ID1 8 ID2 18; |
s******r 发帖数: 1524 | 10 It works. Did not use input for a while, forgot lots of stuff.
【在 h********o 的大作中提到】 : Why you use both LENGTH and INFORMAT statements? also you define your ID1, : ID2 variables as character in the INPUT statement, you should use: : length ID1 $8 ID2 $18; : not : length ID1 8 ID2 18;
|