楼主: joskow
3452 8

SAS Base考试:关于input 中:的使用 [推广有奖]

  • 0关注
  • 1粉丝

博士生

40%

还不是VIP/贵宾

-

威望
0
论坛币
259 个
通用积分
10.3101
学术水平
0 点
热心指数
1 点
信用等级
0 点
经验
587 点
帖子
184
精华
0
在线时间
386 小时
注册时间
2007-10-22
最后登录
2025-6-30

楼主
joskow 发表于 2010-1-7 15:00:16 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
当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;
二维码

扫码加我 拉你入群

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

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

关键词:SAS Base考试 SAS base Base考试 Input Base 考试 SAS Base Input

回帖推荐

bobguy 发表于4楼  查看完整内容

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 ...

本帖被以下文库推荐

沙发
syy_316 发表于 2010-1-7 15:45:41
我也刚遇到这个问题 帮顶下

藤椅
losttemple 发表于 2010-1-7 16:00:23
sas little book看看就知道了
第一个data步需要在country后面加:

板凳
bobguy 发表于 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.
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

报纸
renda_shitou 发表于 2010-1-11 14:15:11
顶一下!!!

地板
chuixue 发表于 2010-1-14 10:51:31
Good point! Thanks!

7
hongbo2009 在职认证  发表于 2010-1-14 15:20:56
我运行了一下,不加:也行啊!

8
joskow 发表于 2010-1-14 16:43:52
在sas中run了一下,用不用:结果都没有差别。

但第一个data步里input语句的$8. 会把后面的0读入,应该把$8.改为$

9
joskow 发表于 2010-1-18 16:55:42
汗,这两段程序是50题里的,看来还是要仔细看啊。

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

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