DATA Step, Macro, Functions and more

Summary table with p values

Regular Contributor
Posts: 182

Summary table with p values

Hello all

Assume I have a dataset with 2 variables:

1) Group - character variable, with 3 levels: Treatment 1, Treatment 2 and Control.

2) Y - Numeric variable

I wish to product a summary statistics table, with mean, standard deviation and median for all 3 categories, which is easy, using PROC TABULATE. But, I also wish to have another column at the end, with p values of a t test comparing the means of the Treatment 1 vs. Control and Treatment 2 vs. Control. In other words, the last column, will have a missing value for the first row (can't compare control to itself), and two p values in the other two rows.

I did something, I wouldn't even upload the code, it is very very long and complicated. There must be an easy way of doing it. Can you assist me with some tips on how to do it gently and efficiently ?

Thank you !

Input (numbers are arbitrary):

2Treatment 111
3Treatment 222

Requested Output (numbers are arbitrary):

VariableMeanStandard DeviationMedianP value
Treatment 110490.001
Treatment 2205170.785
Super User
Super User
Posts: 9,599

Re: Summary table with p values


Why not use proc means with output out=?

With regards to you requested output, I don't know what model you are using so guessing a bit.  First, put:

ods trace on;

Before your model procedure and run it.  This will print to the log each of the objects that are created by the model.  Next, once you have highlighted the objects you want to use put:

ods output <object>=<dataset>;

This will create a dataset <dataset> with the data from <object>.  Now that you have proc means output and the object output it is just a matter of merging the two together.

Regular Contributor
Posts: 182

Re: Summary table with p values

PROC MEANS will give me a t-test of each variable vs. 0, I wish to have a t-test of each variable vs. the control group.

Ask a Question
Discussion stats
  • 2 replies
  • 2 in conversation