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”]
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:
- 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:
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!! 🤟
共同学习,写下你的评论
评论加载中...
作者其他优质文章