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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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