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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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