BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
michokwu
Quartz | Level 8

Hi experts,

 

I made a simple line graph using proc sgplot; however, I believe that combining the summary statistics table generated using the proc means command in the same plot may be more intuitive.Can anyone help with this. Attached: graph and table

 

Thank you, 

 
1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Use an XAXISTABLE. Here is a simulation of how your code probably looks, and how you would use the XAXISTABLE. I put the variable on one statement, but you can put them on multiple statements if you want different visual attributes for each variable.

proc summary data=sashelp.class nway;
class age;
var weight;
output out=sumdata mean=mean median=median n=n;
run;

proc sgplot data=sumdata;
xaxis type=discrete;
series x=age y=n;
xaxistable n mean median;
run;

Hope this helps!

Dan

View solution in original post

4 REPLIES 4
ballardw
Super User

More helpful would be including the code you used to create the Proc Means output, the SGPLOT code and example data. Data is best provided as data step code to allow everyone to see the properties of variables and so we can run code against the created data.

 

Depending on the actual data set used for plotting you likely want an XAXISTABLE statement, if plotting the summarized data.

Otherwise you may want an annotate data set of the summarized values (likely more complex).

michokwu
Quartz | Level 8

Thanks for the feedback,  due to network issues I was unable to access the application and retrieve the info you required

DanH_sas
SAS Super FREQ

Use an XAXISTABLE. Here is a simulation of how your code probably looks, and how you would use the XAXISTABLE. I put the variable on one statement, but you can put them on multiple statements if you want different visual attributes for each variable.

proc summary data=sashelp.class nway;
class age;
var weight;
output out=sumdata mean=mean median=median n=n;
run;

proc sgplot data=sumdata;
xaxis type=discrete;
series x=age y=n;
xaxistable n mean median;
run;

Hope this helps!

Dan

michokwu
Quartz | Level 8

It works. Thank you!

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1120 views
  • 0 likes
  • 3 in conversation