Simple Question About Box Plots

Reply
New Contributor
Posts: 2

Simple Question About Box Plots

This is ridiculously simple... I am sorry for even having to ask it, but I am brand new to SAS and have been struggling with this problem for almost 6 hours!

I am trying to create a box plot for a class assignment...

Given the data set:

Cross    Self

23.500  17.375

12.000  20.375

21.000  20.000

22.000  20.000

19.125  18.375

21.550  18.625

22.125  18.625

20.375  15.250

18.250  16.500

21.625  18.000

23.250  16.250

21.000  18.000

22.125  12.750

23.000  15.500

12.000  18.000

I now need to create two box plots for the Cross column and Self column. So far, I have tried running the proc univariate, proc sort the data, and then proc boxplot. I did the univariate and proc sort for each column seperately. I need these two box plots to be side by side and vertical.

Any help is appreciated, I am at my wits end.

Thanks!

Respected Advisor
Posts: 3,777

Re: Simple Question About Box Plots

One way is to make a CATEGORY for CROSS and SELF.

data cross;
   do grp='Cross','Self';
     
input y @;
      output;
     
end;
  
cards;
23.500  17.375
12.000  20.375
21.000  20.000
22.000  20.000
19.125  18.375
21.550  18.625
22.125  18.625
20.375  15.250
18.250  16.500
21.625  18.000
23.250  16.250
21.000  18.000
22.125  12.750
23.000  15.500
12.000  18.000
;;;;
   run;
proc sort data=cross;
   by grp;
   run;
proc sgplot;
  
vbox y / category=grp;
   run;
  
quit;
New Contributor
Posts: 2

Re: Simple Question About Box Plots

I tried putting this code in verbatim, but was still not able to get the box plots... I am at a complete loss here. After messing with the code for a while I really don't know what else to try. There weren't any Error messages in the log... just not output either. If I am doing something really stupid, please let me know. This is / was my first solo attempt at SAS and I have never used any other computer languages prior to this.

Thank you for your time on this. It's very appreciated.

Super User
Super User
Posts: 6,502

Re: Simple Question About Box Plots

You need to tell the statistical graphics procs where to make the graph.  Turn on an ODS destination.

ODS HTML ;

proc sg....

...

ODS HTML CLOSE;

Ask a Question
Discussion stats
  • 3 replies
  • 198 views
  • 0 likes
  • 3 in conversation