Hello,
I am trying to figure out how to boxplot the information below. I have been using the below equation and many other variations in SAS and has not been working. Not sure its possible, but would like assistance on trying to boxplot the data. Any suggestions would be great.
proc boxplot data=work.wtloss;
plot pre*post wtloss;
run;
pat_id | pre_weight | post_weight |
1 | 165 | 160 |
2 | 202 | 200 |
3 | 256 | 259 |
4 | 155 | 156 |
5 | 135 | 134 |
6 | 175 | 162 |
7 | 180 | 187 |
8 | 174 | 172 |
9 | 136 | 138 |
10 | 168 | 162 |
11 | 207 | 197 |
12 | 155 | 155 |
13 | 220 | 205 |
14 | 163 | 153 |
15 | 159 | 150 |
16 | 253 | 255 |
17 | 138 | 128 |
18 | 287 | 280 |
19 | 177 | 171 |
20 | 181 | 170 |
21 | 148 | 154 |
22 | 167 | 170 |
23 | 190 | 180 |
24 | 165 | 154 |
25 | 155 | 150 |
26 | 153 | 145 |
27 | 205 | 206 |
28 | 186 | 184 |
29 | 178 | 166 |
30 | 129 | 132 |
31 | 125 | 127 |
32 | 165 | 169 |
Your data set is not structured properly to permit boxplots to be drawn by PROC BOXPLOT.
data wtloss1;
set wtloss;
length time $ 4;
time='PRE';
wt=pre_weight;
output;
time='POST';
wt=post_weight;
output;
drop pre_weight post_weight;
run;
proc boxplot data=wtloss1;
plot wt*time;
run;
Having said that, I think this is the WRONG boxplot to analyze the data. This seems to be paired measurements of weight, and the true quantity of interest is the difference between PRE and POST. In that case, you want to compute the difference in a DATA step, and then create a boxplot of the difference.
Your data set is not structured properly to permit boxplots to be drawn by PROC BOXPLOT.
data wtloss1;
set wtloss;
length time $ 4;
time='PRE';
wt=pre_weight;
output;
time='POST';
wt=post_weight;
output;
drop pre_weight post_weight;
run;
proc boxplot data=wtloss1;
plot wt*time;
run;
Having said that, I think this is the WRONG boxplot to analyze the data. This seems to be paired measurements of weight, and the true quantity of interest is the difference between PRE and POST. In that case, you want to compute the difference in a DATA step, and then create a boxplot of the difference.
Hello Paige,
So, do you think its better to just boxplot each group separately, by pat id and pre weight and pat id and post weight?
@Joliek44 wrote:
Hello Paige,
So, do you think its better to just boxplot each group separately, by pat id and pre weight and pat id and post weight?
No, this is not my recommendation. My recommendation is to create a boxplot of the differences. I don't think boxplot of PRE and boxplot of POST (in any manner of display) is not helpful here. But that's my understanding, an educated guess really, because you really haven't stated why you are analyzing this data and what you want to get out of the analysis.
Yes, for sure. I did run the data and got boxplot done. Thank you.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.