Quartz | Level 8

## Plot table and graph

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
SAS Super FREQ

## Re: Plot table and graph

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

4 REPLIES 4
Super User

## Re: Plot table and graph

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).

Quartz | Level 8

## Re: Plot table and graph

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

SAS Super FREQ

## Re: Plot table and graph

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

Quartz | Level 8

## Re: Plot table and graph

It works. Thank you!

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