继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

SAS Baseline 的写法

乌然娅措
关注TA
已关注
手记 64
粉丝 22
获赞 12

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!! 🤟

打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP