楼主: Imasasor
9370 20

input读入原始数据,datalines和txt中的区别? [推广有奖]

11
ziyenano 发表于 2012-12-2 11:59:46
webgu 发表于 2012-12-2 09:03
81 的是候,是相当于flowover的,要下一行读。但结果为什么是
22
4444
应该是和cardimage有关~
当cardimage起作用的时候,每一行不足80字节的,填充空格到80字节;
input testnum $81.;
在flowover选项下,观测长度不够,直接跳过,选取下一行观测填入变量;不过我调试了 nocardimage和cardimage,发现没有区别,不知道是不是
我版本的故障

12
ziyenano 发表于 2012-12-2 12:02:21
pobel 发表于 2012-12-2 10:02
好像确实和80的倍数有关系:

data demo;
应该是和cardimage有关~

13
webgu 发表于 2012-12-2 12:08:33
ziyenano 发表于 2012-12-2 11:59
应该是和cardimage有关~
当cardimage起作用的时候,每一行不足80字节的,填充空格到80字节;
input tes ...
options nocardimage;
这个选项和操作系统有关。好像windows系统不支持。在IBM的MVS大型机上据说可以。
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

14
ziyenano 发表于 2012-12-2 12:18:24
webgu 发表于 2012-12-2 12:08
options nocardimage;
这个选项和操作系统有关。好像windows系统不支持。在IBM的MVS大型机上据说可以。
那还真没办法了~

15
pobel 在职认证  发表于 2012-12-2 12:18:35
webgu 发表于 2012-12-2 12:08
options nocardimage;
这个选项和操作系统有关。好像windows系统不支持。在IBM的MVS大型机上据说可以。
This is from SAS Support communities:
Why not just ask SAS to tell you how long the line is?

data _null_;
  infile cards length=len ;
  input @;
  put len= _infile_;
cards;
short line
short line
....+...10....+...20....+...30....+...40....+...50....+...60....+...70....+...80....+...90
short line
run;

len=80 short line
len=80 short line
len=160
....+...10....+...20....+...30....+...40....+...50....+...60....+...70....+...80....+...90

len=160
short line

In general it is a multiple of 80.  (IBM punch cards have 80 postions.) It seems once it bumps up past a multiple of 80 boundary it stays there.
If you are running this in background then the line length of the input stream might be longer.  If your input is from a file on an IBM mainframe or other system where the operating system can set the record length then SAS will most likely understand that.
和谐拯救危机

16
webgu 发表于 2012-12-2 13:35:05
pobel 发表于 2012-12-2 10:02
好像确实和80的倍数有关系:

data demo;
补足pad后,重复10次 以填满80?
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

17
pobel 在职认证  发表于 2012-12-2 14:28:22
webgu 发表于 2012-12-2 13:35
补足pad后,重复10次 以填满80?
应该是根据DATALINE数据的长度在其后补充空格(或其他控制字符?)使其长度为80或80的倍数,并且不小于前一行的长度,即如果第二行补齐到了160,第三行数据即使只有一个字符,也会补齐到160,而不是80.

补完后按照正常的input语句执行。
  1. options linesize=200;
  2. data demo;
  3.    infile datalines pad;
  4.    input  testnum  $20. @@;
  5.    if _n_=1 then list;
  6.    n+1;
  7.    put n= z2. " Begin^" _infile_"^End";
  8. datalines;
  9. 1
  10. 22
  11. 333
  12. 11111111112222222222333333333344444444445555555555666666666677777777778888888888HEHE
  13. 4444
  14. ;
复制代码
已有 3 人评分学术水平 热心指数 信用等级 收起 理由
hopewell + 1 + 1 + 1 精彩帖子
ziyenano + 1 + 1 + 1 观点有启发
webgu + 2 + 2 + 2 观点有启发

总评分: 学术水平 + 4  热心指数 + 4  信用等级 + 4   查看全部评分

和谐拯救危机

18
webgu 发表于 2012-12-2 15:21:36
pobel 发表于 2012-12-2 14:28
应该是根据DATALINE数据的长度在其后补充空格(或其他控制字符?)使其长度为80或80的倍数,并且不小于前 ...
呵呵,终于水落石出,非常感谢 pobel  大俠。
SAS资源
1. SAS 微信:StatsThinking
2. SAS QQ群:348941365

19
zhentao 发表于 2012-12-3 10:17:06
pobel 发表于 2012-12-2 10:02
好像确实和80的倍数有关系:

data demo;
有意思。

20
FB_FLORA 发表于 2014-11-17 16:20:47
受教,刚好遇到类似的问题

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 08:18