Change from baseline and descriptives

Regular Contributor
Posts: 181

Change from baseline and descriptives

[ Edited ]

Hello all,


I have a dataset looking like this:


ID = Subject ID

Stage = Stage of clinical trial (Baseline, Visit1, Visit2, Visit3,...)

Var1 = First numerical variable

Var2 = Second numerical variable

Var3 = Thirs numerical variable

Var4 = Fourth numerical variable



I wish to calculate for each variable the change from baseline, while including the baseline row for each subject (unlike the SAS paer showing how to do it while withdrawing the baseline row). Is there a simple way of doing it ? My final output should have 4 more variables, for the baseline row they will all be 0, for other rows they will be the difference.


Thank you !

Super User
Super User
Posts: 9,441

Re: Change from baseline and descriptives



Sorry, this is not really a question, but a job description.  Stats programmers are employed to produce these types of tables.  I can't tell you the answer as your company should have its own standards, and mine are IP.  


There are some examples out there which the Phuse team have come up with which may help:


Although I don't necessarily say this is the best approach.  I am not sure what you find difficult - merge dataset with dataset where baseline flag=Y (you are using SDTM/ADaM data per industry standards right?).  Then you can subtract base from value.  Don't use proc tabulate, use proc means, and output the results to a dataset as you will want to do more processing.  For graphs check out Sanjay's excellent blog with loads of examples of all graphs:

Frequent Contributor
Posts: 146

Re: Change from baseline and descriptives


For the second point, if you want to use proc tablate, use the class statement and you will have the proc tabulate by  stages.


For the first one, you could do it like you say, with retains, but i will not set to zero the change, i will set it to missing, because if you want to calculate mean and SE, cero observations will be not well calculated.


For the thirst, I recomend you to use a template of GTL, doing something like in this example

Super User
Posts: 6,642

Re: Change from baseline and descriptives

You have to be able to sort your data so that the baseline visit comes first:


proc sort data=have;

by id stage;



If that gives you the proper order, you could use it with:


data want;

set have;

by id;

if then do;

   baseline1=.; baseline2=.; baseline3=.; baseline4=.;


retain baseline1-baseline4;

if stage='Baseline' then do;

   baseline1=var1; baseline2=var2; baseline3=var3; baseline4=var4;

   cfb1=0; cfb2=0; cfb3=0; cfb4=0;


else do;

   cfb1=var1 - baseline1;

   cfb2 = var2 - baseline2;

   cfb3 = var3 - baseline3;

   cfb4 = var4 - baseline4;


drop baseline1-baseline4;



Good luck.

Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation