BookmarkSubscribeRSS Feed
AmitKB
Fluorite | Level 6
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
4 REPLIES 4
DanH_sas
SAS Super FREQ
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!
AmitKB
Fluorite | Level 6
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
DanH_sas
SAS Super FREQ
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;
AmitKB
Fluorite | Level 6
Hi Dan,
Thanks a lot.

Regards,

Amit
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
  • 6471 views
  • 0 likes
  • 2 in conversation