我正在 SAS 平台上工作,我有一个对象表,另一个表保存针对该对象的注释。一个对象可以有多个注释。作为
object
ID | Name | Other Attributes
1 obj ...
Comment
ID | Comment | object_ID | type
1 first 1 custom
2 Second 1 custom
我想创建一个cast_comm表,其单行中有逗号分隔的评论
proc sql noprint;
create table cast_comm as
select distinct O.ID,C.Comment
from Comments as C, Object as O
where O.ID = C.Object_ID
and C.type = "custom"
quit;
我想要表格为
cast_comm
ID | Comments
1 First, Second
各位,我应该用什么方法来做到这一点?感谢您的支持。
最佳答案
在 proc sql 中没有可使用的组 concat; 您可以在连接后使用数据步骤:
data cast_comm_concat;
set cast_comm;
by id; /*make sure it's sorted*/
length comments $ 1000 ;
retain comments;
if (first.id) then do;
comments="";
end;
comments=catx(",",comments,comment);
if last.id then do;
output;
end;
run;
关于mysql - 如何更新具有彼此串联的多行的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48396627/