09-29-2015 07:50 AM - edited 09-29-2015 08:47 AM
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 !
09-29-2015 08:09 AM
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: https://code.google.com/p/phuse-scripts/
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:
09-29-2015 08:13 AM
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
09-29-2015 07:40 PM
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:
if first.id then do;
baseline1=.; baseline2=.; baseline3=.; baseline4=.;
if stage='Baseline' then do;
baseline1=var1; baseline2=var2; baseline3=var3; baseline4=var4;
cfb1=0; cfb2=0; cfb3=0; cfb4=0;
cfb1=var1 - baseline1;
cfb2 = var2 - baseline2;
cfb3 = var3 - baseline3;
cfb4 = var4 - baseline4;