楼主: Arsaces
3649 4

如何纵向合并一个逻辑库里所有的数据集?数据集结构一致 [推广有奖]

  • 2关注
  • 2粉丝

硕士生

78%

还不是VIP/贵宾

-

威望
0
论坛币
5421 个
通用积分
10.9939
学术水平
8 点
热心指数
8 点
信用等级
7 点
经验
1652 点
帖子
66
精华
0
在线时间
248 小时
注册时间
2012-10-6
最后登录
2023-5-6

5论坛币
如题,哪位大神可以帮忙解答一下。因为生成的数据集名字比较混乱,没法像set dat1-dat100这样合并。

最佳答案

wwang111 查看完整内容

libname aaa "your-dataset-path"; data _null_; set sashelp.vtable end=last; where libname="AAA"; if _n_=1 then call execute("data wanted; set aaa."||strip(memname)); else call execute("aaa."||strip(memname)); if last then call execute(";run;") ; run;
关键词:数据集 逻辑库 Set 合并数据集 纵向合并 set sas
沙发
wwang111 发表于 2016-8-26 20:33:01 |只看作者 |坛友微信交流群
libname aaa "your-dataset-path";
data _null_;
set sashelp.vtable end=last;
  where libname="AAA";
    if _n_=1 then call execute("data wanted; set aaa."||strip(memname));
     else call execute("aaa."||strip(memname));
    if last then call execute(";run;") ;
run;
只有一个罗纳尔多

使用道具

藤椅
Arsaces 发表于 2016-8-26 22:12:58 |只看作者 |坛友微信交流群
wwang111 发表于 2016-8-26 21:15
libname aaa "your-dataset-path";
data _null_;
set sashelp.vtable end=last;
非常感谢回复,我试了:
data _null_;
set sashelp.vtable end=last;
where libname="temp";
if _n_=1 then call execute("data wanted; set temp."||strip(memname));
else call execute("temp."||strip(memname));
if last then call execute(";run;") ;
run;
/*-----------------------------------------------------------------------------------------------------------------*/
结果:
data _null_;
77   set sashelp.vtable end=last;
78   where libname="temp";
79   if _n_=1 then call execute("data wanted; set temp."||strip(memname));
80   else call execute("temp."||strip(memname));
81   if last then call execute(";run;") ;
82   run;

NOTE: 从数据集 SASHELP.VTABLE. 读取了 0 个观测
      WHERE libname='temp';
NOTE: “DATA 语句”所用时间(总处理时间):
      实际时间          1.01 秒
      CPU 时间          1.01 秒
/*-----------------------------------------------------------------------------------------------------------------*/
不知道哪里出了问题?

使用道具

板凳
wwang111 发表于 2016-8-26 22:35:59 |只看作者 |坛友微信交流群
where libname="TEMP"; 这里需要大写

使用道具

报纸
Arsaces 发表于 2016-8-26 23:03:01 |只看作者 |坛友微信交流群
wwang111 发表于 2016-8-26 22:35
where libname="TEMP"; 这里需要大写
非常感谢~

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-1 14:20