全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1428 10
2017-02-19
悬赏 60 个论坛币 未解决
复制代码
以id=1为例
visit=2为AB中A的基线,visit=6为A的疗后数据
visit=6为AB中B的基线,visit=10为B的疗后数据

希望得到的数据
id treat treat1 x0 x1;
1   AB    A     1  2
1   AB    B     2  3
2   BA    B     4  5
2   AB    A     5  6

二维码

扫码加我 拉你入群

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

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

全部回复
2017-2-19 09:28:24
复制代码
二维码

扫码加我 拉你入群

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

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

2017-2-19 18:45:05
data wanted;
set aaa;
retain treat1 x0 x1;
x1=x;
x0=lag(x1);
if visit=6 then treat1=substr(treat,1,1);
else if visit=10 then treat1=substr(treat,2,1);
if lag(id) ne id then delete;
drop x visit;
run;
二维码

扫码加我 拉你入群

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

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

2017-2-20 07:52:41
data aaa1;
set aaa;
if visit=6 then  treat1=substr(treat, 1,1);
else if visit>6 then  treat1=substr(treat, 2,1);
run;
proc sort; by id treat1;run;

data baseline(drop=visit);
set aaa(rename=(x=x0));
if visit=2 then  do;        treat1=substr(treat, 1,1); output; end;
else if visit=6 then do;  treat1=substr(treat, 2,1); output; end;
run;
proc sort; by id treat1;run;

data aaa2(rename=(x=x1)); ;
merge aaa1(in=a) baseline(in=b);
by id treat1;
if a and b;
run;
proc sort data=aaa2 out=aaa3(drop= visit);
by id visit;
run;
二维码

扫码加我 拉你入群

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

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

2017-2-20 10:54:08
lovexialulu 发表于 2017-2-19 09:28
请跟帖以出售60论坛币的形式,我来购买,谢谢!
二维码

扫码加我 拉你入群

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

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

2017-2-20 10:54:30
sherry123 发表于 2017-2-20 07:52
data aaa1;
set aaa;
if visit=6 then  treat1=substr(treat, 1,1);
请跟帖以出售60论坛币的形式,我来购买,谢谢!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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