## Display histogram and descriptive stats ( mean N ) with proc Sgplot

Frequent Contributor
Posts: 99

# Display histogram and descriptive stats ( mean N ) with proc Sgplot

Hi All,
I want to generate a histogram with descriptive stats ( mean, N, # missing etc) using proc sgplot.
This will be similiar to the inset statement in proc univariate.

Thanks,

Amit
SAS Super FREQ
Posts: 1,123

## Re: Display histogram and descriptive stats ( mean N ) with proc Sgplot

The descriptive statistics are not automatically available to you in SGPLOT; however, if you know the values, you can add them to the graph using the INSET statement in SGPLOT.

Thanks!
Frequent Contributor
Posts: 99

## Re: Display histogram and descriptive stats ( mean N ) with proc Sgplot

Hi Dan,
Thanks a lot. Can I use macro variables to output the descriptive statistics.
Can you show me a dummy example where I get say mean from proc means and display it with the histogram.

Thanks a lot for all your help.

Regards,

Amit
SAS Super FREQ
Posts: 1,123

## Re: Display histogram and descriptive stats ( mean N ) with proc Sgplot

Here you go:

proc means data=sashelp.class noprint;
class age sex;
var weight;
output out=meanval mean=;
ways 1;
run;

data _null_;
set meanval;
if ((age eq .) and (sex="F")) then
call symput("FMEAN", put(weight, best6.));
if ((age eq .) and (sex="M")) then
call symput("MMEAN", put(weight, best6.));
run;

proc sgplot data=sashelp.class;
vbar age / response=weight stat=mean;
inset ("Female"="&FMEAN" "Male"="&MMEAN") / border title="Avg. Weight by Gender";
run;
Frequent Contributor
Posts: 99

## Re: Display histogram and descriptive stats ( mean N ) with proc Sgplot

Hi Dan,
Thanks a lot.

Regards,

Amit
Discussion stats
• 4 replies
• 1600 views
• 0 likes
• 2 in conversation