As the first step in the decommissioning of sasCommunity.org the site has been converted to read-only mode.


Here are some tips for How to share your SAS knowledge with your professional network.


Legend for Proc Univariate Using Annotate

From sasCommunity
Jump to: navigation, search

The tip Legend for Proc Univariate Using Annotate notes that although PROC UNIVARIATE is not a SAS/GRAPH procedure, you can use an annotate data set to create and place labels for the legend generated by the HISTOGRAM statement in PROC UNIVARIATE.

Create an annotate data set to place the labels for the legend;

   data anno;
   length function style color $ 8 text $ 25;
   retain xsys "3" ysys "3" size 2 color "black" style "Arial" position "6"; 
   function = "label"; x = 70; y = 80;style = "greek";text = "N(m=80,s=15)";output;  
   function = "move"; x = 65; y = 79;output;
   function = "draw"; x = 69; y = 79;line = 1;output;
   function = "label"; x = 70; y = 85;style = "greek";text = "N(m=90,s=10)";output; 
   function = "move"; x = 65; y = 84;output;
   function = "draw"; x = 69; y = 84;color = "red"; line = 2;output;
   run;

Create the histogram.

   goptions reset = all;
   axis1 label = (f = "Arial" h = 2 "Weight") v = (f = "Arial" h = 1.5);
   axis2 label = (f = "Arial" h = 2 a = 90 "Percent") v = (f = "Arial" h = 1.5);
   title f = "Arial" h = 2 "Weight Distribution";
   proc univariate data = sashelp.class;
   var weight;
   histogram weight/ anno = anno haxis = axis1 vaxis = axis2
   normal (mu = 80 sigma = 15 color = black)
   normal (mu = 90 sigma = 10 color = red);
   run;

Anno.jpg