全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
7119 9
2012-07-15
悬赏 1 个论坛币 未解决
  首先要检讨一下,我英语不好,所以可能影响理解。以下一小段文字摘抄自SAS官方的书"Step-by-Step Programming with Base SAS Software":
Using the SET Statement When Variables Have Different Lengths
If you use the SET statement to concatenate data sets in which the same variable
has different lengths, then the outcome of the concatenation depends on whether the
variable is character or numeric. The SET statement determines the length of variables
as follows:
􀀀 For a character or numeric variable, an explicitly defined length overrides a
default, regardless of the position of the data sets in the SET statement.
􀀀 If two or more data sets explicitly define different lengths for the same numeric
variable, then the variable in the new data set has the same length as the variable
in the data set that appears first in the SET statement.
􀀀 If the length of a character variable differs among data sets, whether or not the
differences are explicit, then the variable in the new data set has the same length
as the variable in the data set that appears first in the SET statement

其第1条和第3条,是不是有矛盾的地方呢?
假如有两个数据集a和b,其各自唯一的文本型变量v,长度分别为默认的8和指定的10,那么:
data n
set a b;
run;
该如何处理n中v的长度?
按照第1条,由于b中v是指定的10,因此长度为10。按照第3条,不管是不是指定的长度,都按a的v长度8来。
到底按哪种方式处理呢?
二维码

扫码加我 拉你入群

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

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

全部回复
2012-7-15 10:48:55

data n; length v $10; set a b; run;

data n;
length v $10;
set a b;
run;
二维码

扫码加我 拉你入群

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

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

2012-7-15 10:54:25
ziyenano 发表于 2012-7-15 10:48
data n;
length v $10;
set a b;
我是想知道这句话表明的意义,我的理解错在哪里。
二维码

扫码加我 拉你入群

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

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

2012-7-15 11:19:05
LiouPerng 发表于 2012-7-15 10:54
我是想知道这句话表明的意义,我的理解错在哪里。
第一条的意思是,如果有明确定义长度(就是以length语句定义明确长度),都将覆盖原先的默认长度,不管数据集在set语句中的位置
二维码

扫码加我 拉你入群

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

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

2012-7-15 15:43:21
学习了
二维码

扫码加我 拉你入群

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

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

2012-7-15 15:47:40
ziyenano 发表于 2012-7-15 11:19
第一条的意思是,如果有明确定义长度(就是以length语句定义明确长度),都将覆盖原先的默认长度,不管数 ...
那么最后一句(字符类型)说,无论不同是不是指定的,新数据集的长度都按SET语句后的第一个数据集的长度来。这里的explicit指的是什么呢?再对比第二条讲的数值型变量,其最后一句也说按第一个长度来,它的explicitly又指什么呢?与字符型有什么不同?
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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