有没有办法附加两个数据集,以便较长的格式优先?
考虑这个简单的示例:
data abc;
length a $2 b $1;
a = "aa";
b= "b";
run;
data def;
length a $1 b $2;
a = "a";
b= "bb";
run;
data ghi;
set abc def;
run;
在此示例中,数据集 ghi 有两个变量,但它们的长度由数据集 abc 中的内容决定。有没有一种方法(无需编写宏)附加两个数据集,以便如果变量名称相同,则较长的长度优先?也就是说,在此示例中,数据集 ghi 中的 a 和 b 的长度均为 2。
Consider this simple example:
data abc;
length a $2 b $1;
a = "aa";
b= "b";
run;
data def;
length a $1 b $2;
a = "a";
b= "bb";
run;
data ghi;
set abc def;
run;
In this example the dataset ghi has two variables but their length is determined by what's in dataset abc. Is there a way (without writing macros) to append two datasets so that if the variable names are the same the longer length takes precedence? That is in this example both a and b in dataset ghi is of length 2.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有太多变量,您可以手动为组合数据集生成长度语句,如下所示。请注意,宏变量值的长度有 32k 字符的限制。这也可能会打乱变量的现有顺序。
If you don't have very many variables, you can manually generate the length statement for your combined dataset like below. Notice that there is the 32k char limit on the length of the macro variable value. This may also mess up the existing order of the variables.