全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3385 8
2010-01-07
当list input读入非标准数值或长于8字符的字符变量时,需要加:

那么,下面两个程序,为什么一个必须加:而另一个不需要。

data test;
input country $8. date mmddyy10.;
cards;
Germany 12/31/2000
France 01/31/2001
;
run;

1---+----10---+----20---+---
son Frank 01/31/89
daughter June 12-25-87
brother Samuel 01/17/51

data work.family;
infile 'file-specification';
input relation $ first_name $ birthdate : mmddyy8.;
run;
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2010-1-7 15:45:41
我也刚遇到这个问题 帮顶下
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-1-7 16:00:23
sas little book看看就知道了
第一个data步需要在country后面加:
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-1-11 10:48:35
joskow 发表于 2010-1-7 15:00
当list input读入非标准数值或长于8字符的字符变量时,需要加:

那么,下面两个程序,为什么一个必须加:而另一个不需要。

data test;
input country $8. date mmddyy10.;
cards;
Germany 12/31/2000
France 01/31/2001
;
run;

1---+----10---+----20---+---
son Frank 01/31/89
daughter June 12-25-87
brother Samuel 01/17/51

data work.family;
infile 'file-specification';
input relation $ first_name $ birthdate : mmddyy8.;
run;
There is a couple of knowledge points here.
1)An informat not only tells SAS how many positions should be read in but also inplies/defines variable length for a char variable.  2)The column modifier has a special input instruction. Here is its definition in this case.

Usually (:) the column modifier is needed for a variable-length record/observation when one also uses informats on an input statement.



:
enables you to specify an informat that the INPUT statement uses to read the variable value. For a character variable, this format modifier reads the value from the next non-blank column until the pointer reaches the next blank column, the defined length of the variable, or the end of the data line, whichever comes first. For a numeric variable, this format modifier reads the value from the next non-blank column until the pointer reaches the next blank column or the end of the data line, whichever comes first.
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-1-11 14:15:11
顶一下!!!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2010-1-14 10:51:31
Good point! Thanks!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群