为了账号安全,请及时绑定邮箱和手机立即绑定

SAS Baseline 的写法

SAS Day 21: Baseline Value

Background:

How do we decide if the Weight Loss program/drug is effective or the laser operation improves the vision? Usually, we compare the weights before and after a program or track the vision before and after the eye laser surgery. The Change From Baseline is a critical measurement of efficacy analysis. Therefore, it is very crucial to record the correct baseline records.

Baseline Definition:
The last non-missing record before or on the day of treatment.

Problem: Generate the baseline information with a dummy ADEFF  dataset.

[caption id=“attachment_1403” align=“alignnone” width=“1280”]image

suju / Pixabay[/caption]

**Solutions: **

  • Create Baseline records with SAS function Merge **
    1. Output Base records
    * 2. Select the Baseline values

    * 3. Merge with the Original datasets

    * 4. Clean the datasets*
data base pbase;
set eff1;
if avisitn<=1 then output base;
else output pbase;
run;

proc sort data=base ;
by usubjid paramcd avisitn;
run;

**Baseline values: last non-missing value before or on the first treatment.;
data base1(keep=usubjid aval paramcd base avisitn rename=(avisitn=avisitn1));
set base(where=(aval ne . ));
by usubjid paramcd avisitn;
if last.paramcd;
rename aval=base;
run;

**merge with original dataset;
data all;
merge eff1(in=a) base1(in=b);
by usubjid paramcd;
*if a and avisitn<avisitn1 then base=.;
if a;
run;

data all;
set all;
if avisitn< avisitn1 then base=.;
run;

Output Dataset:

image

  • Create Baseline records with SAS step **Retain **
    Note: Retain is an easier method with the Definite Avisitn number, or it can get messy.
data base2;
set eff1;
by usubjid paramcd avisitn;
retain base;
if first.paramcd then do;
base=.; end;
if avisitn=1 then do ; base=aval; end;
run;

Output dataset:

image

Summary:

In the clinical industry, the dataset could be more complicated, I prefer to use the Merge method if the dataset structure is complex. If the data is clean and straightforward with a definitive avisitn for baseline, Retain is a better choice.

Note: there are might be various conditions and restrictions for the baseline, such as a test on the same date but different timepoint.

Happy studying!! 🤟

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消