- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
Is there a way to combine proc means with proc ttest across several variables to create a single table that gives mean, sd, median and iqr for different groups as well as a ttest.
This creates an approximation of what I want:
proc means data=sashelp.cars n mean stddev median q1 q3 prt;
class origin;
var msrp invoice MPG_Highway;run;
The difference is that I want origin as columns and the ttest to compare means and medians across origins:
Asia | Europe | USA | ||||||||||||||||||
Variable | N | Mean | Std Dev | Median | Lower Quartile | Upper Quartile | N | Mean | Std Dev | Median | Lower Quartile | Upper Quartile | N | Mean | Std Dev | Median | Lower Quartile | Upper Quartile | Pr > |t| MEDIAN | Pr > |t| MEAN |
MSRP | 158 | 24741.32 | 11321.07 | 23032.5 | 17200 | 28800 | 123 | 48349.8 | 25318.6 | 40590 | 33780 | 56595 | 147 | 28377.44 | 11711.98 | 25520 | 20310 | 33995 | p | p |
Invoice | 158 | 22602.18 | 9842.98 | 20949.5 | 16265 | 26660 | 123 | 44395.08 | 23080.37 | 37575 | 31187 | 51815 | 147 | 25949.34 | 10518.72 | 23217 | 18881 | 30846 | p | p |
MPG_Highway | 158 | 28.26582 | 6.770503 | 27 | 25 | 31 | 123 | 26.00813 | 4.167588 | 26 | 24 | 29 | 147 | 26.01361 | 5.396582 | 26 | 22 | 29 | p | p |
Many thanks
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This produces something close to what you asked for.
proc summary data=sashelp.cars nway stackods;
class origin;
var msrp invoice MPG_Highway;
output out=_stats_ n= mean= stddev= median= q1= q3= prt= /autoname;
run;
I don't know any way to get the t-test of a median.
If you have to have the table laid out EXACTLY as you have shown, that will take a lot more work.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PROC MEANS produces an output data set. PROC TTEST produces an output data set. You merge them together and then PROC REPORT can produce the desired table.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'm looking at about 20 variables which is why I would love an automated process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This produces something close to what you asked for.
proc summary data=sashelp.cars nway stackods;
class origin;
var msrp invoice MPG_Highway;
output out=_stats_ n= mean= stddev= median= q1= q3= prt= /autoname;
run;
I don't know any way to get the t-test of a median.
If you have to have the table laid out EXACTLY as you have shown, that will take a lot more work.
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Perfect - thank you.
Read some more - the t-test is a test of means so asking for a test of medians was a mistake on my part.