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):
ID | Group | X |
---|---|---|
1 | Control | 21 |
2 | Treatment 1 | 11 |
3 | Treatment 2 | 22 |
4 | Control | 23 |
Requested Output (numbers are arbitrary):
Variable | Mean | Standard Deviation | Median | P value |
---|---|---|---|---|
Control | 22 | 7 | 21 | |
Treatment 1 | 10 | 4 | 9 | 0.001 |
Treatment 2 | 20 | 5 | 17 | 0.785 |
Hi,
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.
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.