1st - The easiest way:
If you want to use HIST in your PROC UNIVARIATE procedure and add a vertical line corresponding to the mean of your variable, here is a straightforward way:
proc univariate data=sashelp.class noprint; var height; histogram height / normal(color=big w=2) statref=mean cstatref=crimson wstatref=2; run;
STATREF = allows you to choose which computed value will become your reference line
CSTATREF = allows you to choose the color of your stat reference line
WSTATREF = allows you to choose the width of your stat reference line
Note that I did not find "WSTATREF =" in any SAS document at this stage, I just tried it.
This will give you something that looks like:
2nd - A much more generalizable way with many lines of codes:
Here is a way you can find over the internet, and that would be provided by SAS technical support. You can imagine as well to use such approach with other SAS plotting procedures.
proc means data=sashelp.class noprint; var height; output out=out mean=mean; run; data _null_; set out; call symput('mean',mean); run; proc univariate data=sashelp.class noprint; var height; histogram height / href=&mean hreflabel='Average'; run;
For more information and other tips:
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
Data Literacy is for all, even absolute beginners. Jump on board with this free e-learning and boost your career prospects.