SAS中文论坛

标题: 存档和读档的问题? [打印本页]

作者: shiyiming    时间: 2010-8-16 22:18
标题: 存档和读档的问题?
请问各位前辈,为什么我所做出的结果在sas中看没问题,但若存盘后再重新读取时就出问题了,之间有一些空格会被右边的数据补上,造成字段大乱,请问一下,请如何解决呢?

例:
(存档时我这么写)
data book4;
set book3;
file 'e:\eee\aaa.txt';
put sn $ oq op type odate eq ep
bs $ or $ sax $ sax1 $
age ctype $ mtype tra tel cell bir pi wealth
max;
RUN;

(取档时)
data book;
infile 'e:\eee\aaa.txt';
input sn $ oq op type odate eq ep
bs $ or $ sax $ sax1 $
age ctype $ mtype tra tel cell bir pi wealth
max;
RUN;

档案内容类似
1903 1000 72.1 3 20090616 1000 70.9 B R 男1 67 0 1 0 0 0 19430619 3 70900 1213500
1903 0 79.1 4 20090611 . . S R 男1 67 0 0 0 0 0 19430619 3 . 1213500
1903 1000 83.9 3 20090612 1000 83 B R 男1 67 0 1 0 0 0 19430619 3 83000 1213500
1903 2000 82.1 3 20090624 2000 80 B R 男1 67 0 1 0 0 0 19430619 3 160000 1213500
2006 5000 35.9 4 20090602 5000 37.8 S R 男1 67 0 0 0 0 0 19430619 2 189000 1213500
2006 5000 38.4 3 20090602 5000 37.7 B R 男1 67 0 1 0 0 0 19430619 2 188500 1213500
2006 0 37.9 4 20090602 . . S R 男1 67 0 0 0 0 0 19430619 2 . 1213500
2014 5000 13.9 3 20090601 5000 13.7 B R 男1 67 0 1 0 0 0 19430619 2 68500 1213500
2014 5000 12.95 4 20090601 5000 13.4 S R 男1 67 0 0 0 0 0 19430619 2 67000 1213500
2015 5000 49 3 20090522 5000 48.5 B R 男1 67 0 1 0 0 0 19430619 2 242500 1213500
2015 3000 50.2 3 20090518 3000 51 S R 男1 67 0 1 0 0 0 19430619 3 153000 1213500
2015 2000 48 3 20090616 2000 47.3 B R 男1 67 0 1 0 0 0 19430619 2 94600 1213500
作者: shiyiming    时间: 2010-8-17 08:33
标题: Re: 存档和读档的问题?
看半天看不明白,是把数据集put出来,再input回去的时候出问题了吗? 加dlm选项.
[code:28i8fpvb]data book;
   infile 'e:\eee\aaa.txt' dlm=' ';
   input sn $ oq op type odate eq ep
           bs $ or $ sax $ sax1 $
           age ctype $ mtype tra tel cell bir pi wealth
           max;
RUN;[/code:28i8fpvb]
另外,"男1"分别是2个变量的值,但没空格分隔,是否是笔误




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2