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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

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

View all other training opportunities.

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